[Dnsmasq-discuss] Static leases issues

Simon Kelley simon at thekelleys.org.uk
Mon Jun 29 15:45:16 BST 2020


On 08/06/2020 17:18, Bruno BEAUFILS wrote:
> Hello everyone,
> 
> I have got a static leases issue with dnsmasq 2.80-1 installed as
> Debian Buster package.
> 
> I search the man page and the mailing list archives without any
> success. Thus I try here.
> 
> Here is short summary of what I have.
> 
> I am on a simple LAN with a screenless host running dnsmasq. It is the
> only, and thus main, DHCP server on the network.
> 
> I use the dhcp-authoritative option in dnsmasq configuration.
> 
> It offers a dhcp-range looking like that...
> 
>     dhcp-range=192.168.0.200,192.168.0.250,12h
> 
> ...and a bunch of static lease looking like something like that 
> 
>     dhcp-host=xx:xx:xx:xx:xx:xx,id:*,192.168.0.2,somename
> 
> I want to use a new USB-ethernet adpator on a new laptop.
> 
> On the first connection the host get a IP from the open range
> (192.168.0.203) as it is visible in the logs:
> 
>     Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPDISCOVER(eth1) 12:34:56:78:9a:bc
>     Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPOFFER(eth1) 192.168.0.203 12:34:56:78:9a:bc
>     Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPDISCOVER(eth1) 12:34:56:78:9a:bc
>     Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPOFFER(eth1) 192.168.0.203 12:34:56:78:9a:bc
>     Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPREQUEST(eth1) 192.168.0.203 12:34:56:78:9a:bc
>     Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPACK(eth1) 192.168.0.203 12:34:56:78:9a:bc mechra
> 
> After the first connection I am able to log on the server and add a
> dhcp-host specific to that host. For that I did the following things
> in order :
> 
> 1. stop the dnsmasq server
> 
> 2. remove the leases file
> 
> 3. modify the dnsmasq configuration in order to add the dhcp-host
>    option
> 
>     dhcp-host=00:23:4d:df:a1:d1,id:*,192.168.0.15,somefancyname,24h
>     
> 4. start the dnsmasq server
> 
> After that I unplug the adaptor from the laptop and replug it in order
> for it to get the new IP from the static lease. Unfortunately I always
> get the same "old" adress (192.168.0.203), as the log shows (because
> the client asked it):
> 
>     juin  7 18:05:23 b3 dnsmasq-dhcp[29360]: DHCPREQUEST(eth1) 192.168.0.203 12:34:56:78:9a:bc
>     juin  7 18:05:23 b3 dnsmasq-dhcp[29360]: DHCPACK(eth1) 192.168.0.203 12:34:56:78:9a:bc mechra
> 
> I thought the dnsmasq should have refused the client request of using
> 192.168.0.203 (through a DHCPNAK for instance) and sent it a new
> OFFER with the correct static (192.168.0.15).
> 
> Did I miss something (aka this is normal behavior but I misconfigured
> the whole stuff certainly because I did not understand the
> documentation well enough) or am I struggling with some kind of bug?
> 
> Just in case it matters: all host used in the description are running Debian.
> 

Dnsmasq does have code to do exactly what you want, but I think by
unpluging and replugging the adapter, you're frustrating that because
the DHCP client is going to "SELECTING" mode. Ie it's saying to the DHCP
server "I want this address (the address it had before)" and the DHCP
server has to comply, as long as the address is valid. If you can get
the DHCP server to RENEW the lease (either by making leases short, or
finding a control on the DHCP client) then the renewal will fail and a
DHCPNAK will be sent, which should force the client back to DHCPDISCOVER
state and it will find the new address. The same thing should happen in
INIT-REBOOT state, which I'd expect the client to move to on the
unplug-replug cycle.


The state diagram for a client is here:

https://tools.ietf.org/html/rfc2131#page-35

If you can grab a packet dump of the DHCPREQUEST packet being sent, that
would be useful. If it has both SERVER_IDENTIFIER and REQUESTED_IP
options, then that would explain the behaviour, and put the spotlight on
the client. Actually, a dump of the whole exchange would be useful.


Simon.





More information about the Dnsmasq-discuss mailing list