How do I renew my DHCP lease?

Short of rebooting, how can I release and renew my DHCP lease? It would be useful to know a GUI and terminal method.

I'd especially like to know if there is a means to do this without requiring admin privileges.


Solution 1:

To renew your dhcp lease at the terminal:

sudo dhclient -r; sudo dhclient

Solution 2:

In my case I had to specify which card to renew:

Note: you might want to join the two on one line, as otherwise you might lose the remote connection you're on after the first!

First release the current IP address:

sudo dhclient -r eth0

then renew the IP address

sudo dhclient eth0

.. or do them together to avoid losing connection:

sudo dhclient -r eth0 && sudo dhclient eth0

Solution 3:

In the network drop-down selector from the system tray you can press the network you are already connected to, this will make network-manager ask for a new lease from a DHCP server.

alt text

(This also works for wired networks, but i don't think it works for PPP connections (mobile broadband))

Solution 4:

This works on Ubuntu 12.04 LTS:

sudo service network-manager restart

When I do that, Network Manager asks for a new DHCP lease.

I prefer this to manually (re)starting dhclient because I've had problems by stale dhclient processes (ones not managed by Network Manager) spontaneously and incorrectly reconfiguring my network settings at random points when it's least convenient.