I have been doing some VM testing. I have created and destroyed a large number of VMs on my subnet to test fresh provisioning via puppet. However, it looks like Ubuntu doesn't free a DHCP lease when the system is shut down, and the DHCP lease time is a week. So I have reached a point where I can't get a DHCP lease with a new VM. I could have released the leases on the test VMs manually had I known, but I need to release those leases so I can get my free IPs back. DHCP server is serving some production servers as well, so I can't just nuke all the leases and call it a day.

DHCP server OS is Ubuntu 12.04.4. Using dhcpd for the DHCP server.

  • Did you configure the network as a /24? If you are using RFC1918 addresses you might as well configure your network with a shorter network prefix. A /16 would last a lot longer, and the overhead of storing a lot of leases on the DHCP server is usually negligible.
    – kasperd
    Nov 25, 2015 at 21:38

2 Answers 2


Apparently there is no such elegant method to accomplish the job.

So, let's do it manually.

  • Stop dhcp server.
  • Check your /var/lib/dhcp/dhcpd.leases file and check for the entry. It contains the list of all dhcp leases.
  • Remove the entry carefully and start the dhcp server again.
  • I guess it is a good idea to stop dhcpd before editing dhcpd.leases.
    – kasperd
    Nov 25, 2015 at 21:39
  • Will any active servers that have acquired leases from dhcpd experience any connectivity issues while dhcpd is stopped?
    – cat pants
    Nov 25, 2015 at 22:08
  • @kasperd, you are right. I have updated my answer.
    – Diamond
    Nov 25, 2015 at 22:23
  • @catpants, a restart should not cause any problem.
    – Diamond
    Nov 25, 2015 at 22:23
  • 1
    @catpants As long as the lease doesn't expire while the DHCP server is down, the DHCP clients should be unaffected. Additionally clients usually renew their DHCP lease halfway through their lease time, so if your lease time is a week the DHCP clients should keep their address even if the DHCP server was down for a few days.
    – kasperd
    Nov 25, 2015 at 22:26

There is a utility called dhcp_release that can do this. According to the man page you just pass it the interface, IP address, and MAC address, like so:

sudo dhcp_release enp1s0f0 01:02:03:04:05:06

It is available in the dnsmasq-utils package. I don't know if it works with any DHCP server other than dnsmasq, but it seems like it should. With dnsmasq it is essential, because dnsmasq does so many other things that stopping it for a while so you can manually edit the leases file may cause headaches.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .