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 '15 at 21:38

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 '15 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 '15 at 22:08
  • @kasperd, you are right. I have updated my answer. – Diamond Nov 25 '15 at 22:23
  • @catpants, a restart should not cause any problem. – Diamond Nov 25 '15 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 '15 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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