Can't add a second network device


#1

I tried copying the same network settings as the original device and renaming eth0 to eth1 but when I boot the container there is no second network.

Furthermore even when I comment out the first one, leaving only the second, with the only difference being that the name is eth1 rather than eth0 there is no ip assigned when booted up.

What is going on? It doesn’t seem to like changing the name from anything but eth0

Here are the config settings which work for eth0 but fail as soon as the setting is changed to eth1.

lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.name = eth0
lxc.net.0.hwaddr = 00:16:3e:77:68:67

(Christian Brauner) #2

That has nothing to do with LXC. I suspect your eth0 device has an entry in /etc/network/interfaces whereas eth1 hasn’t so dhcp is not ran against eth1. You need to do so manually or put it in /etc/network/interfaces.
If you want multiple network devices simply do:

lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.name = eth0
lxc.net.0.hwaddr = 00:16:3e:77:68:67 

lxc.net.1.type = veth
lxc.net.1.link = lxcbr0
lxc.net.1.flags = up
lxc.net.1.name = bla
lxc.net.1.hwaddr = 00:16:3e:77:68:68

lxc.net.2.type = veth
lxc.net.2.link = lxcbr0
lxc.net.2.flags = up
lxc.net.2.name = blu
lxc.net.2.hwaddr = 00:16:3e:77:68:69

#3

I have read in other answers about this /etc/network/interfaces file but it doesn’t exist on either host or container systems?

I am using archlinux on both.

EDIT: ok I didn’t need to mess with that file I just had to do lxc.net.1 as in your example which I copy and pasted. Looks ok now. Thanks ! :slight_smile:


(Christian Brauner) #4

That sort of depends on what the default configuration on arch is then.

/etc/netctl/interfaces

or something. Depending on whether one uses netctl or systemd-networkd but the principle should be the same. :slight_smile:


#5

Didn’t need it; see edit :slight_smile: