When you create some containers on a host, e.g.:
sudo lxc-create -n container1 -t ubuntu
sudo lxc-create -n container2 -t ubuntu
the LXC system creates IP address for the hosts on a new subnet, e.g.
lxc-ls --fancy
NAME STATE IPV4 IPV6 AUTOSTART
----------------------------------------------------
container1 RUNNING 10.0.3.143 - NO
container2 RUNNING 10.0.3.12 - NO
The question is, where is the DHCP service which is allocating these addresses, and how can we allocated a fixed IP based on the server name or MAC address?
We tried editing /etc/lxc/default.conf
and adding:
dhcp-host=container1,10.0.3.10
dhcp-host=container2,10.0.3.20
Then stopping and starting the containers and doing sudo service lxc-net restart
but this had no effect.
I could edit /etc/network/interfaces
on each container and hard code an IP instead of using DHCP, but I would rather control it centrally.
Is there a way to do this?