[lxc-users] Configuring LXC containers to use a host bridge under Ubuntu Wily

Mark Constable markc at renta.net
Sat Aug 29 07:08:07 UTC 2015


So not to hijack Peter Steeles CentOS thread I'd like to ask a similar question
about the best way to tweak either the LXC network settings or
/etc/network/interfaces to provide the missing pieces for non-NAT bridging.

I modify lxc-net to bring up a bridge using my "native" internal LAN network range
and this starts up just fine when the lxd deamon is started by systemd but I have
to manually use /etc/rc.local to bind the lxcbr0 bridge to enp4s0f1 (or eth0).

~ egrep -v "^(#|$)" /etc/default/lxc-net
USE_LXC_BRIDGE="true"
LXC_BRIDGE="lxcbr0"
LXC_ADDR="192.168.0.2"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="192.168.0.0/24"
LXC_DHCP_RANGE="192.168.0.3,192.168.0.99"
LXC_DHCP_MAX="96"
LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf
LXC_DOMAIN="lxc"

~ egrep -v "^(#|$)" /etc/rc.local
ifconfig enp4s0f1 up
brctl addif lxcbr0 enp4s0f1
route add default gw 192.168.0.1
echo "
nameserver 192.168.0.2
search lxc" > /etc/resolv.conf

The above has been working for me for 6 months but it's "tacky" and I'd like to
complete these bridging steps "properly". My attempts with /etc/network/interfaces
fail because the bridge is already up via either /etc/network/interfaces or lxc-net.

- is it possible to do these /etc/rc.local steps via lxc-net?

- if not could anyone offer a hint for the correct way to do the above via the
   /etc/network/interfaces file?

I hope to start using LXD for real with public IPs when wily is released and the
above rc.local workaround is not something I'd like to recommend in some blog post
tutorials I intend to write.


More information about the lxc-users mailing list