1

I am running an lxc container which I want to connect to two different bridges (br0 and br1). When I configure the container's config file (/var/lib/lxc/testcontainer/config) as shown below, only the first interface is assigned an IP address:

lxc.network.type = veth
lxc.network.link = br0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:e6:16:c5

lxc.network.type = veth
lxc.network.link = br1
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:c5:16:c5

This is confirmed using lxc-ls:

NAME              STATE   AUTOSTART GROUPS IPV4          IPV6 
testcontainer     RUNNING 1         -      192.168.1.6   -    

And using ifconfig from within the container:

eth0      Link encap:Ethernet  HWaddr 00:16:3e:e6:16:c5  
          inet addr:192.168.1.6  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::216:3eff:fee6:16c5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:440 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:48388 (48.3 KB)  TX bytes:1576 (1.5 KB)

eth1      Link encap:Ethernet  HWaddr 00:16:3e:c5:16:c5  
          inet6 addr: fe80::216:3eff:fec5:16c5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2796 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:521109 (521.1 KB)  TX bytes:648 (648.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Switching the order of the network interfaces inside the configuration file results in the other interface (which was previously unassigned) showing and IPv4 address.

What is needed to be assigned an IPv4 on the second interface?

0

Seeing no static IP defined in your config snippet, I assume you're using DHCP/dnsmasq. In this case you need to enable the network config for eth1. In most templates by default, only the eth0 has been setup with a default network config script.

Depending on the template/OS you're using, you should edit the network config file and add something in the line of:

auto eth1
iface eth1 inet dhcp

(this example is for debian/ubuntu container)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.