Documenting Problems That Were Difficult To Find The Answer To

Adding Static Leases to LXC in Ubuntu Trusty Tahr 14.04.2 LTS

If you want to have more control over DHCP in the default LXC installation in Ubuntu Trusty Tahr then you can edit the file /etc/default/lxc-net to suit you.

It is recommended that you uncomment the line:


…because the /etc/lxc/dnsmasq.conf file is where you will add static lease configuration information later.

Note that you do not need to make any changes to /etc/init/lxc-net.conf as the settings in /etc/default/lxc-net will take preference.

Next you will want to find the MAC addresses of your LXC containers:

# grep /var/lib/lxc/*/config
/var/lib/lxc/lxctutorial/ = 00:16:3e:32:9a:a4
/var/lib/lxc/webserver/ = 00:16:3e:0c:5b:1b
/var/lib/lxc/mailserver/ = 00:16:3e:ca:cb:02

Then assign them the static addresses you want them to have in /etc/lxc/dnsmasq.conf e.g.:

# static leases
# dhcp-host=[][,id:|*][,set:][,][,][,][,ignore]

Now you need two steps to make sure this takes effect:

stop lxc-net
echo "" >/var/lib/misc/dnsmasq.lxcbr0.leases # erase current leases
start lxc-net

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: