DHCP Release/Renew in Ubuntu

In Windows, we can simply do the following to get an IP from DHCP:

#To release
ipconfig /release
 
#To renew
ipconfig /renew

How to do it in Linux, or Ubuntu more specifically?

For a while, I’ve done the following in Ubuntu when trying to get an IP from DHCP:

#first, down the interface
sudo ifdown eth0
 
#then, up it again and it will get a lease from DHCP
sudo ifup eth0

This worked, sort of, but I just felt turning something on/off didn’t seem like the right way to do it. Then I found out about dhclient. Use it as follows:

#To release your current lease
sudo dhclient -r
 
#To get another lease
sudo dhclient

As simple as that. Enjoy!

Add a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.