I'm running DHCPD (isc-dhcp-4.2.4) on an Ubuntu 14.04 system. The var/lib/dhcp/dhcpd.leases file is getting pretty huge (350MB). Looking in it, there's historical data going back many months about leases that have long since expired. How do I purge the old info? Presumably stopping dhcpd and deleting the file is a bad idea because then it will forget recent leases that might still be relevant?
[edit] Apparently dhcpd is supposed to auto-purge the leases file once an hour, but this isn't happening for me. Apparently this is down to a permissions problem - the /var/lib/dhcp directory and contents are ownwd by root:root but the server runs as dhcpd:dhcpd. I tried changing the ownership as follows:-
sudo service isc-dhcp-server stop
sudo chown -R dhcpd:dhcpd /var/lib/dhcp/
sudo service isc-dhcp-server start
but after this the ownership of the directory, dhcpd.leases and dhcpd.leases~ reverted to root:root.
So how do I sort out directory ownership vs the user:group running the dhcpd process to get auto-purge to work?
From the manual
man dhcpd.leases
:AFAIK that may fail when file system permissions on the directory
/var/lib/dhcpd
prevent the unprivileged user dhcpd runs as from creating that temporary database there and then the leases file will continue to grow.Change ownership of
/var/lib/dhcpd
to the dhcpd user.You do not need to delete it, only remove what's not needed.
You can optimize this by editing the file (and not save until ready) and then perform DHCPD stop / file save / DHCPD start in a matter of seconds or even faster. It even worked under 1s for me; that's if you don't want downtime.