Question: How to create an lxc container using lxcbr0 and virbr0 network interfaces?
LXC uses the virtualization management service to support network bridging for containers, libvirtd uses bridge network virbr0 and lxc-net.service uses bridge of lxcbr0. To start virbr0 bridge start libvirt service and create a container using network.link as virbr0:
virbr0: flags=4163mtu 1500 inet 192.168.122.x netmask 255.255.255.0 broadcast 192.168.1xx.2xx ether 52:54:00:be:71:21 txqueuelen 0 (Ethernet)
lxcbr0: flags=4163mtu 1500 inet 10.220.239.1 netmask 255.255.255.0 broadcast 0.0.0.0 inet6 fe80::fc37:c0ff:fe01:78d7 prefixlen 64 scopeid 0x20
# cat /container/ol6ctr4/config # Template used to create this container: /usr/share/lxc/templates/lxc-oracle # Parameters passed to the template: # For additional config options, please look at lxc.container.conf(5) lxc.network.type = veth lxc.network.link = virbr0
Container:
# ip addr 11: eth0@if12:mtu 1500 qdisc pfifo_fast state UP qlen 1000 inet 192.168.122.xx/24 brd 192.168.122.255 scope global dynamic eth0
To start the lxcbr0 bridge, start the lxc-net service and create a container using network.link as lxcbr0. The following then verifies that the container got the IP address assigned from the lxcbr0 address range.
# cat /container/ol5ctr1/config # Template used to create this container: /usr/share/lxc/templates/lxc-oracle # Parameters passed to the template: --release=5.latest -a x86_64 --baseurl=http://yum.oracle.com/repo/OracleLinux/OL5/latest/x86_64 # For additional config options, please look at lxc.container.conf(5) lxc.network.type = veth lxc.network.link = lxcbr0 lxc.network.flags = up lxc.network.hwaddr = 00:16:3e:52:59:7d lxc.rootfs = /container/ol5ctr1/rootfs # Common configuration lxc.include = /usr/share/lxc/config/oracle.common.conf # Container configuration for Oracle Linux 5.latest lxc.arch = x86_64 lxc.utsname = ol5ctr1 lxc.cap.drop = sys_resource lxc.cap.drop = setfcap setpcap lxc.autodev = 0 # Networking lxc.network.name = eth0 lxc.network.mtu = 1500
# ifconfig lxcbr0 lxcbr0: flags=4163mtu 1500 inet 10.112.62.XX netmask 255.255.255.0 broadcast 0.0.0.0
Container:
# ifconfig eth0 Link encap:Ethernet HWaddr 00:16:3E:52:59:7D inet addr:10.112.62.xx Bcast:10.112.62.xxx Mask:255.255.255.0