Thursday, February 19, 2015

how to add network interface to lxc container

1- create a new interface for separate from the old one and assign ip 10.0.4.1/24

~$ sudo brctl addbr lxcbr1
~$ sudo ifconfig lxcbr1 10.0.4.1/24 up

2- edit container ubuntu-test to add two network interface, one belong to lxcbr0 and another below to lxcbr1 by modify the network config in /var/lib/lxc/ubuntu-test/config to below

lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = lxcbr0
lxc.network.hwaddr = 00:16:3e:4b:cf:96

lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = lxcbr1
lxc.network.hwaddr = 00:16:3e:a7:ff:84


3- run the lxc and see the the new interface appear

~$ sudo lxc-start -n ubuntu-test


1 comment: