[lxc-users] LXD assigning static IP's at start tp containers

Mark Constable markc at renta.net
Sat May 16 17:24:08 UTC 2015


On Sat, 16 May 2015 09:56:04 AM Kevin LaTona wrote:
> I was thinking that by just updating the /etc/default/lxc-net config file
> from the 10.x.x.x to a 192.168.x.x that was going to do it for me.

Try this, first make sure ifupdown and NetworkManager are not interfering...

mv /etc/network/interfaces /etc/network/interfaces.orig
ll /etc/NetworkManager/system-connections/
  # make sure each [connection] section has "autoconnect=false"

edit /etc/default/lxc-net to something like below...

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

Manually run these where 192.168.x.1 is your eth gateway...

ifconfig # eth0 up but without an IP, lxcbr0 should be 192.168.x.x

brctl addif lxcbr0 eth0
route add default gw 192.168.x.1
echo "nameserver 8.8.8.8" > /etc/resolv.conf

Make sure you can ping google.com on the host and bring up a container.
A default legacy container will attempt dhcp and should be able to hit
your gw routers dhcp server. For an unprivileged container you have to..

lxc exec <container name> bash
/etc/init.d/networking restart

This is a crude guide to a fairly simple default setup. If your container
gets a 192.168.x.x IP then your mostly there bar some extra fine tuning.



More information about the lxc-users mailing list