I setup my own dhcp server for containers instead of LXD’s dhcp server.
I did “lxc network set lxdbr0 ipv4.dhcp false”, created a “dhcp” container with static ip (I used images:alpine/3.8 to make it small), installed and configured dnsmasq. New containers now get ip4 addresses from the “dhcp” container.
In the dnsmasq configuration file, I specified that container a1 should get a specific ip address. When I launch a1 for the first time, it gets the desired address.
When I delete a1 and relaunch another container with the same name “a1”, dnsmasq does not give it the specified ip address, because that address is alread leased to the dead container. This is the error I get:
dhcp daemon.warn dnsmasq-dhcp: not using configured address 10.232.110.142 because it is leased to 00:16:3e:30:74:eb
How can I force dnsmasq to ignore the lease and give to “a1” the address specified for it?
How does the LXD dhcp server handle this situation? Configuring the host-ip association in raw.dnsmasq does not work in LXD 3.x (which is why I want to use a separate dhcp server). But I noticed that if I put the ip address in the host’s /etc/hosts, then it does reassign the same ip address.