How to create multiple network interfaces in an LXC container.

You can specify more than one interface in your lxc configuration file.  Just add the interfaces one after the other and use lxc-create to create your container, like this:

lxc.network.mtu = 1500
lxc.network.type = veth
lxc.network.name = eth0
lxc.network.link = br0
lxc.network.ipv4 = 107.20.135.109
lxc.network.flags = up

lxc.network.type = veth
lxc.network.link = br1
lxc.network.ipv4 = 192.168.0.63/24
lxc.network.name = eth1
lxc.network.flags = up

Inside your container, if you do an ifconfig, you should see two network interfaces.

This was not documented very well and I found this after a bit of frustrated googling.

 

This entry was posted in lxc and tagged , . Bookmark the permalink.

Comments are closed.