DHCP lot of UNUSED dynamic leases

Hi every body.
Config: ipfire 2.27 core 169 on PI3 Red internal Wifi / Green switch + external AP

I got abnormal disconnections for clients. Had a look at page DHCP of ipfire and seems that DHCP never clean unsued old leases. Ones of them outdated for quite a year…
As the range I affected was a bit tiny ( from 20 to 49 ) I suspect it could be a cause of bad reneewing clients addresses when all the addrsses have all been used once, but NOT sure.
For the moment enlarged the pool to 20-99 to see…
Seems that it’ll be more academic to clean the unsued leases after several days or one month or …
May be I can do this by hand in /var/state/dhcp/dhcpd-leases for all with mention binding state free.
Beg for your lights.
Thanks a lot for that beauteful software !

If the leases have a line through them then they have expired and are available again if needed.

What doesn’t happen is that the old expired leases are not cleared out from the table after a certain while.

If you have a large list of leases that are not expired (ie crossed through with a line) then you have some machine on your network that is making multiple lease requests.


Only a few addresses are active and all of them known as ok.
A lot of inactive ( in fact all the pool affected ) part of them coming from ramdom mac adresses of tablet Samsung T720 ( which is the questionable default option for new network )

If the tablet is changing MAC addresses with each new connection ( some new ‘security feature’ :roll_eyes: ), there is a big chance that all the IPs of your pool are used.

The DHCP server identifies client devices by their MAC ( which should be unique by definition ). Usually ISC dhcpd tries to hand out the same IP to a specific client ( identified by MAC ). Therefore expired leases aren’t deleted. If all IPs are associated to a MAC, dhcpd tries to use an old expired lease.
Changing the MAC very often, produces this situation.

Ok guys Ithanks a lot.
I agree with all your answers ( I am not realy a newbie or I am a newbie for years ;-)… as we say in french " I am not born under the last rain " .
More seriously, the question I asked myself was:
Could the process of attributing or renewing addresses be altered by the fact of all the addresses of the pool having been once already affected ?
Having enlarged the pool of dynamic addresses to get rid of this eventuality , I’ll keep an eye on what happens.
Regards from Greece

I don’t think it is quite easy to delete the information about expired leases. I haven’t looked inside the sources of dhcpd, but I suspect that the information is stored internally in the running process.

To avoid a lengthy list, I recommend to keep the dynamic pool very small ( 3-4 IPs ) and define for all known devices a fixed lease.
This is possible, if you know all the devices possible. A new device in the network receives a dynamic lease. This can be changed to a fixed definition in the WebGUI.
As said in my former post, a device changing its identity ( MAC ) frequently makes this process a bit harder. But this behaviour is configured in the device and should be changed there.
Annotation: A ‘well behaviour’ of devices can be forced by an empty dynamic pool ( end<start ). :wink:

I did look at this once and if I remember correctly the leases file is a binary one so it is not easy to do things with that file but it should be possible to do something with the WUI dhcpd.cgi page. When the leases are written to the page you would have to detect if the lease expires date was older than some value and then not print that line into the table. You would still want to keep a view of expired leases for some time after they expired.

The question is how long to keep them on view.
My dhcp current dynamic leases has some that expired in November 2021.

It’s something I have thought about but haven’t had the time to get round to yet.


One possible solution could be to delete all dynamic leases, which have been converted to fixed leases. But this only handles a part of the problem, not the entries of ‘changing identity devices’. For those you cannot define a relation (MAC, IP) as fixed lease.

1 Like

OK Guys thanks a lot
First I’ll have a look on what happens to my network after having enlarged the pool; cause it was the reason i paid attention to this…
I ll give informatio if I notice anything special

“Current dynamic leases” can be seen in the file

Database file: /var/state/dhcp/dhcpd.leases

If you want to “clear” “Current dynamic leases” you can try going to
WUI–>Network–>DHCP Server

  1. uncheck “Enabled:”
  2. click “Save”
  3. check “Enabled:”
  4. click “Save”



Agreed. This wipes the table shown on the page.
Nevertheless the behaviour of dhcpd doesn’t change. Expired leases are hold for use in the future. So the lengthy table after some time shows the state of dhcpd, as intended by the page.

If both the green and blue subnets are disabled the current dynamic leases table on the wui page disappears but also the dhcpd.leases file is cleared. This is because disabling both green and blue subnets turns off the dhcp server, which you can see from the services page.

When you enable at least one of the subnets then the dhcp server is turned on again and it starts with an empty lease file, which of course means it takes longer to get leases now because it no longer has any knowledge of previously provided leases, although that time difference is probably minimal. Not sure of the time impact if you had many hundreds of clients that needed to get a lease at the same time but probably still not huge.

I tested this on my system and confirmed it. The old expired dynamic leases from my blue subnet are no longer in the dhcpd.leases file. It is empty except for the text at the top.

I agree with @bbitsch on just leaving this file as it is normally, because if all the available IP’s have been assigned with a lease in the past then when a new lease is required dhcp will start to use the expired leases in some form of order. So it is not like having the expired leases in the file prevents getting new leases assigned.

I do agree that it could be useful to not see the expired leases in the Current Dynamic Leases table on the dhcp server WUI page so I do still intend to work on that and provide a checkbox to select hiding of the expired leases in the table but leave them in the dhcpd.leases file.


Thanks, I learned a lot again. The operation of the software is correct…
@bonnietwin if you plan working on the subject, the checkbox to show or not globally expired leases is fine. May I suggest if the work is not too heavy, also introducing a button on the WUI (as for the Add box) to individually erase those that we want any more. Of course it’s up to you :wink:

1 Like