DHCPD Leases, no way to clean the file?

Simon Hobson simon at thehobsons.co.uk
Sun Aug 21 20:01:10 UTC 2022


Jorge Bastos <mysql.jorge at decimal.pt> wrote:

> I've started using DHCPD, and noticed that the lease file is not "cleaned",
> What I mean is, if some cliente request IP, and get .....11, and after two days/another time request again after the lease time ends, and the ......11 is already in someone else, it will get a new IP, so far so good.

I assume here you mean the client gets an address xx.xx.xx.11 rather than it gets 11 addresses ?

> But the lease file stays with the information about the old lease, aswell the new one.

It will have multiple entries for the same address for a short while - compile time option, default is one hour between cleanups.

Each hour (default), the server will write out a fresh copy of the leases file from it’s internal tables. This fresh copy will contain only the most recent lease for each IP - it will not contain any older versions. Where your leases file is stored, you’ll see both dhcpd.leases and dhcpd.leases~. The latter is the previous leases file.
The process used is to write out the new file (to a different temporary file name); iff that succeeds, then it will rename dhcpd.leases to dhcpd.leases~ (deleting the previous file named dhcpd.lease~), and rename the temporary new file to dhcpd.leases. It is done this way so that no matter what happens (e.g. disk full, server crash, power cut, whatever), you will not be left without a valid leases file.
It may be that for some reason this process is failing (in which case your leases file will continue to grow until the disk is full), it may be worth looking into that.


But in normal operation, you should see older lease file entries disappear after no more than one hour.


Simon



More information about the dhcp-users mailing list