Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
sudo /etc/init.d/networking restart works for me on 11.10 server (this is in ec2: ami-6ba27502). Also: sudo service networking restart returns restart: Unknown instance:. –  Adam Monsen Feb 8 '12 at 22:27

6 Answers 6

up vote 12 down vote accepted

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))

share|improve this answer

To renew your dhcp lease at the terminal:

sudo dhclient -r; sudo dhclient
share|improve this answer
    
I think sudo service networking restart is a better way to go. What you suggest didn't work for me on an 11.10 box with dhclient3. Instead, I ended up with two DHCP clients running: one dhclient3 and one dhclient. See ubuntuforums.org/showthread.php?t=1868368 –  Adam Monsen Feb 7 '12 at 19:14
    
@AdamMonsen Does restarting the networking service actually work with NetworkManager? –  rakslice Dec 13 '12 at 0:21
    
@AdamMonsen restarting networking does not seem to renew the dhcp lease for me –  dogmatic69 Apr 9 at 21:36
    
sudo service network-manager restart in Ubuntu 13.10 64-bit desktop appears to properly restart network stuff and renew my DCHP lease. (From askubuntu.com/a/230751/2273 ) –  Adam Monsen Apr 9 at 22:02

Maverick comes with nmcli, a command line interface to the network manager.

I can't see a simple way of telling it to renew a lease, but running:

nmcli con

Gets you a connection list, and running:

nmcli con down id 'Connection Name'
nmcli con up id 'Connection Name'

Takes the connection down and back up. It may be possible to do something similar with the device instead.

The connection list seems to include all connections, so this will probably work with PPTP and VPN connections too.

share|improve this answer

Having just upgraded to Maverick Meerkat Beta 1, something broke in my standard, vanilla eth0 configuration which I've not debugged yet. The quick and dirty workaround has been

sudo dhclient

which notices that there was a (possibly dead) client already and obtains a new lease:

There is already a pid file /var/run/dhclient.pid with pid 2436
killed old client process, removed PID file
Internet Systems Consortium DHCP Client V3.1.3
Listening on LPF/eth0/00:1a:92:24:9c:85
Sending on   LPF/eth0/00:1a:92:24:9c:85
Sending on   Socket/fallback
DHCPDISCOVER on vboxnet0 to 255.255.255.255 port 67 interval 3
DHCPREQUEST of 192.168.2.2 on eth0 to 255.255.255.255 port 67
DHCPACK of 192.168.2.2 from 192.168.2.1
bound to 192.168.2.2 -- renewal in 118389830 seconds.

This isn't a fix, just a hack. I'll follow-up when I figure what went bad.

share|improve this answer

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

First release the current IP address:

sudo dhclient -r eth0

then renew the IP address

sudo dhclient eth0
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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