[Dnsmasq-discuss] dnsmasq caching lease file?

Simon Kelley simon at thekelleys.org.uk
Mon Oct 15 12:05:56 BST 2012


On 14/10/12 00:41, Tautvydas Bruzas wrote:
> Hi,
>
> I am running into the issue where dnsmasq seems to be caching dhcp
> leases for a defined period of time and doesn't reload them on SIGHUP. I
> have and openstack install and it uses dnsmasq to serve VMs and IP
> address, it starts dnsmasq with these options:
>
> --strict-order --bind-interfaces --conf-file= --domain=novalocal
> --pid-file=/var/lib/nova/
> networks/nova-br100.pid --listen-address=10.15.0.6 --except-interface=lo
> --dhcp-range=10.15.0.2,static,7200s --dhcp-lease-max=65536
> --dhcp-hostsfile=/var/lib/nova/networks/nova-br100.conf
> --dhcp-script=/usr/bin/nova-dhcpbridge --leasefile-ro
>
> Usually when you launch a new VM it gets added to the
> /var/lib/nova/networks/nova-br100.conf file and dnsmasq get SIGHUP to
> reload that file. Which works fine. However I've noticed that if you
> already had an IP assigned and it's reused (you're launching new VM with
> different mac, but it should get the old IP), dnsmasq doesn't update
> it's cache? I've tried setting cache_size to 0 and that doesn't affect
> anything. In the strace for the dnsmasq I still see the old name for the
> VM so I assume it's cached somewhere. In the source file I've traced the
> SIGHUP and it seems like it should clear cache and reload (there is a
> function for that: void clear_cache_and_reload(time_t now)), but it
> doesn't do it. Not sure if it's a bug or if it's intended by design.
>
> I'd really appreciate if someone would help me on this. As I said I've
> tried looking at the source code, and it didn't seem like it's
> dhcp_read_ethers(); that reads from /etc/ethers file, doesn't look like
> dhcp_update_configs(daemon->dhcp_conf) that one seems to be for
> /etc/hosts file?
>

You're confusing configuration with DHCP leases. If you map an IP 
address to MAC address in the nova-br100.conf file, then the VM will 
take out a DHCP for a fixed time. Until that lease expires, the IP 
address will not be given to another VM, even if you change the 
nova-br100.conf file. Look at the logs: dnsmasq will log that it's not 
using the configured address, because it's in use elsewhere.


If you need to re-used IP addresses, you need to make the lease-times 
short (but the minimum is one minute) or configure your VMs to release 
their DHCP lease as part of the shut-down process, or use the utility 
dhcp_release that's supplied with the dnsmasq source to force the DHCP 
lease to be removed.

Cheers,

Simon.






More information about the Dnsmasq-discuss mailing list