Linux – How to manually release a DHCP lease on the DHCP server itself

dhcplinuxUbuntu

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.

Best Answer

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.