[Dnsmasq-discuss] Possible lease matching/reuse bug
Jerome Vuarand
jerome.vuarand at gmail.com
Tue Sep 8 08:19:00 BST 2020
Hi,
I believe I'm triggering a bug where a static dhcp-host config does't
seem to match the existing lease the second time that client connects.
I'm running dnsmasq from a Raspberry Pi acting as a WiFi access point.
I have a mixture of IoT devices connecting to it. I'd like most
clients to get a dynamic IP address, but some to get a static one
based on their name, so I use a combination of dhcp-range and
dhcp-host. I have the following config:
interface=ap0
dhcp-range=192.168.4.100,192.168.4.250,255.255.255.0,24h
domain=example.com
dhcp-script=/home/pi/my_web_ui/dnsmasq_script
dhcp-leasefile=/var/run/dnsmasq.leases
dhcp-host=target
And I have an entry in /etc/hosts that associate target to
192.168.4.2, the dnsmasq server itself is 192.168.4.1.
The clients are dumb and forget their leases on reboot. I can get my
setup to work the first time a client connects. However if it loses
power, reconnects and asks for a new IP, it seems that dnsmasq can't
match the previous lease.
The first time the "target" client connects, it gets the right IP, and
I get that in the lease file:
1550252252 b8:27:eb:a6:d4:d6 192.168.4.2 target
ff:eb:a6:d4:d6:00:01:00:01:23:f7:fb:8a:b8:27:eb:a6:d4:d6
If I reboot it, it gets the IP 192.168.4.200, and I get two leases in
the file with the same MAC address:
1550252386 b8:27:eb:a6:d4:d6 192.168.4.200 *
ff:eb:a6:d4:d6:00:01:00:01:23:f7:fb:8b:b8:27:eb:a6:d4:d6
1550252252 b8:27:eb:a6:d4:d6 192.168.4.2 target
ff:eb:a6:d4:d6:00:01:00:01:23:f7:fb:8a:b8:27:eb:a6:d4:d6
Then if I reboot it again, it gets the correct IP 192.168.4.2, and
updates the second lease:
1550252386 b8:27:eb:a6:d4:d6 192.168.4.200 *
ff:eb:a6:d4:d6:00:01:00:01:23:f7:fb:8b:b8:27:eb:a6:d4:d6
1550252496 b8:27:eb:a6:d4:d6 192.168.4.2 target
ff:eb:a6:d4:d6:00:01:00:01:23:f7:fb:8a:b8:27:eb:a6:d4:d6
I did a lot of tests with different variants of dhcp-host, and I was
about to report them when I realized the problem doesn't happen 100%
of the time. Sometimes it takes 3 or more reboots to get the second
lease in the file, and from then on it alternates between the two
addresses. Whenever the wrong IP is assigned, I get an extra syslog
line which reads:
club dnsmasq-dhcp[1211]: not using configured address 192.168.4.2
because it is leased to b8:27:eb:a6:d4:d6
But then the next time I don't get the line and I get the correct IP.
The only workaround I got so far is to put the MAC address in the
dhcp-host line, but I'd really like to avoid that as they are very
likely to change from time to time.
The latest version on that distro is as follows:
Dnsmasq version 2.80 Copyright (c) 2000-2018 Simon Kelley
Compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua
TFTP conntrack ipset auth DNSSEC loop-detect inotify dumpfile
I don't think I would be able to compile it myself to test the latest.
Cheers,
Jérôme.
More information about the Dnsmasq-discuss
mailing list