[lxc-users] multiple containers on the same vlan

Mark Constable markc at renta.net
Mon Jun 15 14:21:17 UTC 2015


On Mon, 15 Jun 2015 10:33:14 AM Genco Yilmaz wrote:
> > Is there any way to link multiple containers without using softbridge
> > +veth pair by using network.type vlan? or what is the best practice
> > in this type of topology?

If you just want to expose containers to the hosts private or public network
then you don't need to use a vlan. Just tweak the lxcbr0 host bridge to sit
on the same network as the host and your container network settings can work
without alteration and all containers are accessible from the hosts network
and also each other. For instance I use this on a ubuntu systemd host (because
I'm not smart enough to know how to do this part properly) in /etc/rc.local...

sleep 1 && {
  ifconfig eth0 up
  sleep 1
  brctl addif lxcbr0 eth0
  sleep 1
  route add default gw 192.168.0.1
  echo "
nameserver 192.168.0.2
search mydomain.com" > /etc/resolv.conf
}

~ cat /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.2,192.168.0.54"
LXC_DHCP_MAX="53"
LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf
LXC_DOMAIN="mydomain.com"



More information about the lxc-users mailing list