Add multiple nic to lxc containers

I am trying to attach multiple nic to a lxc continer. i can attach them to the container but the second interface is not getting any ip. status is showing as down.

OS Version: Ubuntu 22.04
LXD/LXC Version:
Client version: 5.0.0
Server version: 5.0.0

Kernel Version: 5.15.0-40-generic

What i am trying to do is as follows.

limits.cpu: “1”
limits.memory: 1GB
user.user-data: |
package_upgrade: true
description: LXD profile for apps
name: apps
used_by: []

lxc storage create k8s-storage dir source=/srv/lxd-storage/

lxc network create k8sexnet ipv6.address=none ipv4.address= ipv4.nat=true
lxc network create k8sintnet ipv6.address=none ipv4.address= ipv4.nat=false

lxc launch ubuntu:22.04 haproxy -p apps -s k8s-storage
lxc config device add haproxy eth0 nic name=eth0 nictype=bridged parent=k8sexnet ipv4.address=
lxc config device add haproxy eth1 nic name=eth1 nictype=bridged parent=k8sintnet ipv4.address=

lxc info haproxy
Name: haproxy
Type: container
Architecture: x86_64
PID: 53939
Created: 2022/06/23 20:10 UTC
Last Used: 2022/06/23 20:10 UTC

Processes: 44
CPU usage:
CPU usage (in seconds): 21
Memory usage:
Memory (current): 147.58MiB
Network usage:
Type: broadcast
State: UP
Host interface: veth62522cd2
MAC address: 00:16:3e:28:de:8f
MTU: 1500
Bytes received: 25.13MB
Bytes sent: 127.46kB
Packets received: 2146
Packets sent: 1676
IP addresses:
inet: (global)
inet6: fe80::216:3eff:fe28:de8f/64 (link)
Type: broadcast
State: DOWN
Host interface: veth16516397
MAC address: 00:16:3e:e9:b5:94
MTU: 1500
Bytes received: 0B
Bytes sent: 0B
Packets received: 0
Packets sent: 0
IP addresses:
Type: loopback
State: UP
MTU: 65536
Bytes received: 3.91kB
Bytes sent: 3.91kB
Packets received: 38
Packets sent: 38
IP addresses:
inet: (local)
inet6: ::1/128 (local)

Am i missing something?

Our images by default only have config for eth0, so you’ll need to update the instances network config inside to use dhcp or static ip.

@tomp thanks for the pointer. i have added a new network config for the interface and its working as expected now.

1 Like