[Dnsmasq-discuss] Lease comes back after removing

A C dnsmasq6pJH at acarver.net
Mon Jun 24 01:38:05 BST 2019


On 2019-06-23 11:08, Geert Stappers wrote:
> On Sun, Jun 23, 2019 at 09:33:21AM -0700, A C wrote:
>> On 2019-06-23 03:32, Geert Stappers wrote:
>>> On 23-06-2019 08:06, A C wrote:
>>>
>>>> I'm having trouble removing leases from my system.  I have a client that
>>>> accepted a lease in my DHCP range before I remembered to put it in
>>>> /etc/ethers and /etc/hosts to give it a static lease.
>>>>
>>>> I turned off the client, stopped dnsmasq, removed the lease file entry
>>>> in /var/lib/misc/dnsmasq.leases and then restarted dnsmasq.  Then I
>>>> restarted the client.  It again found the original lease in my DHCP
>>>> range instead of picking one from /etc/ethers (in fact it reports "not
>>>> giving name ap.lan to the DHCP lease of 10.0.200.102 because the name
>>>> exists in /etc/hosts with address 10.0.0.252").
> 
> Please check if I understand that,
> that the configuration is simular to this:
> 
> /etc/dnsmasq.conf:
> 
> dchp-range=10.0.200.101-10.0.200.150    
> readethers
> 
> 
> /etc/ethers
> 00:00:ca:fe:be:ef   ap.lan
> 
> 
> /etc/hosts
> 
> 10.0.0.252  ap.lan

I have:

/etc/dnsmasq.conf:
read-ethers ###(there is a dash)
dhcp-range=10.0.200.100,10.0.200.105,255.255.0.0,12h
### My netmask is actually 255.255.0.0 on the network, all dhcp leases
are in 10.0.200.x, static assignments are in other subnets

/etc/ethers:
00:25:9C:1C:0A:C3 ap.lan
### and others

/etc/hosts:
10.0.0.252  ap.lan
### and others


> 
> 
> 
>>>> How can I fully purge the lease and get it to start over?  The client is
>>>> an embedded device and has no memory of the lease once I power cycle it
>>>> so somehow dnsmasq is remembering even though the lease file was purged.
>>>>
>>> Recently I had simular sympthoms, infact still have them.
>>>
>>> It give me the akward feeling that `readethers` does not work as I expect.
>>>
>>> Because it was the first time that i used Dnsmasq with  /etc/ethers I
>>> choose to continue with the netboots I have to do.
>>>
>>>
>>> Yes, most likely will it bite me another time.
>>>
>>> Meanwhile send your report of (successfull) mapping of IPv4 address on
>>> MAC address through  /etc/ethers
>>
>> /etc/ethers works fine for me, I have 50 clients listed in it, no issues. 
> 
> Acknowledge on that.  ( and no questions asked why it works fine )
> 
> 
>> My only issue is when I forget to add a client to the list
>> prior to first putting it online and it acquires a lease from the DHCP
>> lease pool instead of the IP I want to give it via the combination of
>> ethers/hosts.  After that I have extreme difficulty purging the lease to
>> force a new address.
> 
> 
> My /etc/ethers has a line like
> 
> 00:02:b0:ef:f0:ef  kornuit
> 
> Doing `host kornuit` returns correctly the IPv4 address that is in DNS.
> (other DNS as dnsmasq  ( no kornuit entry in /etc/hosts ))
> 
> 
> I also stopped dnsmasq, removed the lease file and restarted dnsmasq.
> 
> Did another PXE netboot  ( consider it an embedded device, it has no
> memory of previous lease )
> 
> Server kornuit got the IPv4 address as before, one from the Dnsmasq
> DHCP range. Where it looks like a persistent DHCP lease, do I think
> that it is algoritme that hands out each time the same IPv4 address.
> 
> Thing I need to verify is if dnsmasq does do a DNS-lookup on 'kornuit'
> after reading /etc/ethers.

host ap.lan localhost (run on the same server as dnsmasq) returns
10.0.0.252 as expected.

Turned off the device, stopped dnsmasq, removed the lease from the lease
file, restarted dnsmasq and then restarted the device.  I get the old
DHCP range lease instead of the one defined in hosts.

If I add a host entry (with an IP outside of the DHCP range) and an
ethers entry for a device bore I ever plug it into the network I will
correctly get a static lease of the IP I define in hosts.  If I forget
to do that, the device picks up a lease from the DHCP range and then
it's a massive fight to get rid of it.  Sometimes I have to leave the
device disconnected for a few days so the lease expires on its own
(regardless of deleting the lease) and then I can switch the IP.

There seems to be some kind of persistence that exists outside of just
the lease file but I don't know where that is.  This isn't the first
time this has happened and it's happened with different embedded devices
and non-embedded devices (cameras, AP's, IoTs, phones, etc.) there just
seems to be sticky lease data somewhere.



More information about the Dnsmasq-discuss mailing list