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?

  • Do you have one-lease-per-client configured? How many devices are we talking about? What's the lease-time? You should run into few problems deleting or manually editing the lease-file, but I don't know why you'd do it in the first place. 350MB is not that huge. Maybe you also ran into a permissions issue where dhcpd can't rotate the file?
    – Lenniey
    Feb 27, 2019 at 12:53
  • 37 devices. default-lease-time is 600 (seconds?!). No one-lease-per-client set. I've got a Perl script that greps out the active lease info and it takes 5 minutes to grok the file.
    – kbro
    Feb 27, 2019 at 13:07
  • Looks like permissions - /var/lib/dhcp is owned by root:root but dhcpd is running as dchpd:dhcpd. Thanks.
    – kbro
    Feb 27, 2019 at 13:10
  • 600s? That's short for 37 devices...ok well, I think your question is answered.
    – Lenniey
    Feb 27, 2019 at 13:10
  • Hmm... so I edited the lease time in etc/dhcp/dhcpd.conf, did "sudo chown -R dhcpd:dhcpd /var/lib/dhcp", then "sudo service isc-dhcp-server restart" and the directory and lease files went back to root:root ownership!
    – kbro
    Feb 27, 2019 at 13:28

2 Answers 2


From the manual man dhcpd.leases:

In order to prevent the lease database from growing without bound, the file is rewritten from time to time. First, a temporary lease database is created and all known leases are dumped to it. Then, the old lease database is renamed /var/lib/dhcpd/dhcpd.leases~. Finally, the newly written lease database is moved into place.

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.

  • sudo service isc-dhcp-server stop ; sudo chown -R dhcpd:dhcpd /var/lib/dhcp/ ; sudo service isc-dhcp-server start - ownership reverts to root:root
    – kbro
    Feb 27, 2019 at 13:37
  • 1
    See other comments - seems that Ubuntu 14.04 has a buggy version of isc-dhcp so for now the best I can do is work around the problem by running "sudo chown -R dhcpd:dhcpd /var/lib/dhcp" after restarting the daemon.
    – kbro
    Feb 27, 2019 at 13:58

You do not need to delete it, only remove what's not needed.

  • Stop DHCPD server.
  • Edit your dhcpd.leases file and remove what entries you no longer need
  • Save the file and start DHCPD server.

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.

  • 2
    Manually editing the leases file is not a good idea at all. If it's 350MB like in this case, this isn't practical anyway.
    – Sven
    Feb 27, 2019 at 13:02
  • I can sort such a file in a few minutes and did so in the past. Nothing unpractical about it. I did not mean go line by line. Advanced text processing editors exists since the MS-DOS era.
    – Overmind
    Feb 27, 2019 at 13:29
  • Sorry, this is completely nonsensical. There is a problem with the system configuration and this should be fixed in the proper way.
    – Sven
    Feb 27, 2019 at 13:31
  • The case I specified is for a 'no lease time expiration' situation. The initial post did not say that a lease time is set. Some companies want historical data and let very large or infinite lease times.
    – Overmind
    Feb 27, 2019 at 13:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.