Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Renewing a DHCP lease Internet
If you have a cable modem, you may have to sometimes "renew your DHCP lease" — in other words, get a new IP address from your Internet provider's DHCP server. This is particularly useful when your ISP has recently been suffering connectivity problems and your earlier established connection was disrupted. There are two ways to do this: the 'normal' way, and also the 'shell' way. This is shortened somewhat from this webpage...

The 'normal' way involves the Network preference pane in the System Preferences application. Click on the "Show" pull-down menu and select either 'Network Port Configurations' or 'Active Network Ports,' depending on whether you're using 10.2 or an earlier version. Click off the box next to your network port (usually 'Built-In Ethernet,' unless you're using AirPort), then hit 'Apply Now.' Then click it back on and hit 'Apply Now' again. And as Emeril might say ... BAM! New DHCP lease.

You can also do this through the Terminal. First type the Unix command sudo ipconfig set en0 BOOTP, and then the command sudo ipconfig set en0 DHCP. I aliased the two commands together as 'new-ip' (you put them both on the same line, using a semi-colon to separate them). Don't know how to use aliases? Read this hint (and possibly this one, if you're in 10.2).

If you're working with IP addresses through the terminal, ipconfig getifaddr en0 is another useful one; it should show you your current IP address.

[Editor's note: That last command will only work if you're not hiding behind a router of some sort. If you are, it will instead return your local machine's IP number.]
    •    
  • Currently 2.83 / 5
  You rated: 5 / 5 (6 votes cast)
 
[155,227 views]  

Renewing a DHCP lease | 20 comments | Create New Account
Click here to return to the 'Renewing a DHCP lease' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
How I do it....
Authored by: Garvey on Feb 12, '03 10:40:19AM

Under the Network CP, in the "DHCP Client ID"area, I change my name then hit apply.
And away it goes, BADDA BING a new IP comes in.
I have been doing this since OS 9.



[ Reply to This | # ]
How I do it....
Authored by: mantei on Feb 12, '03 11:24:41AM

Another possibility: Create a location in Network preferences,
and name it location1 or the like. Duplicate the location and
name it location2. Whenever your DHCP connection dies, just
go to the Apple menu under Location and choose the other location.
You then don't have to wait for Network Preferences to open.
(I think I read this suggestion here, but in any event it's not
original with me.)

P.S. I had wanted to post this as a response to the original post
from WCityMike, but no "Reply to this" link was available. Am
I missing something?



[ Reply to This | # ]
Probably missing something
Authored by: robg on Feb 12, '03 01:50:24PM

It's hiding in the blue bar at the top of the comment area, next to Refresh...

-rob.



[ Reply to This | # ]
How I do it....
Authored by: rackerby on Feb 12, '03 07:44:03PM

This could be a problem on a network with limited IPs, since you are taking two leases when you give the server a new client ID. 'The Network Port Configurations' release/renew method is better in this regard.



[ Reply to This | # ]
Forcing AirPort to lengthen DHCP searches
Authored by: Spencerian on Feb 12, '03 03:49:00PM

I've been using these lease control commands (which did appear in an earlier hint) to try to make an AirPort card in my PowerBook G4 1GHz obtain a DHCP lease from a third-party wireless hub (A Lucent AeroNet, I believe). On AirPort, I get the dreaded 169.254.x.x self-assigned address. On another PowerBook, before the company went to a hidden network, I used AirPort just fine.

Using ifconfig commands to release DHCP to try to get a real address on my company net does no good. Normal DHCP leasing over our 100Mb Ethernet works fine. Other Windows clients use things just fine. Apple's info on this matter did little good. We use WEP, and, with the key in place, AirPort does pick up the existence of the network (it's hidden) and the wireless admin does see my card and MAC address.

Some thoughts: I think AirPort is too impatient to find a DHCP server. I think it spends too little time searching, and gives up too early, therefore giving the 169.254 default self-assigned address.

Is there a UNIX command to force a network interface (in this case, the interface for AirPort) to wait longer while searching for a DHCP server?



[ Reply to This | # ]
A bit
Authored by: rackerby on Feb 12, '03 07:46:02PM

This could be a problem on a network with limited IPs, since you are taking two leases when you give the server a new client ID. 'The Network Port Configurations' release/renew method is better in this regard.



[ Reply to This | # ]
How about ifconfig instead?
Authored by: Kip on Feb 12, '03 11:48:23PM

This works for me:

sudo ifconfig en1 down ; sudo ifconfig en1 up

I just went to my DHCP server and deleted my lease and then ran the commands above and got a new lease.

en1 being my Airport interface



[ Reply to This | # ]
How about ifconfig instead?
Authored by: cl0r0x70 on Jan 23, '04 02:39:42PM

This is the way most pros do it on other Unix flavors.



[ Reply to This | # ]
Renewing a DHCP lease (Command line)
Authored by: corvus on Apr 24, '03 10:37:43AM

sudo ipconfig set <interface name> DHCP

is all you need.

For example:

sudo ipconfig set en1 DHCP



[ Reply to This | # ]
Renewing a DHCP lease (Command line)
Authored by: theRegent on Jun 20, '03 09:44:03PM

I'm getting a "command not found" error message with that solution... Do you know... is there a package that you've added that with or some such explanation?

---
It's a little more starry eyed than thin-lipped.
http://regency.newarcadia.com/



[ Reply to This | # ]
Renewing a DHCP lease (Command line)
Authored by: seann on Oct 11, '03 05:34:10PM

bsdtools



[ Reply to This | # ]
Renewing a DHCP lease
Authored by: robg on Feb 21, '06 07:43:20AM

Received via email:

"The ipconfig set en BOOTP causes OS X to release the address; then ipconfig set en DHCP causes OS X to attempt to get a new address. On some networks, the behavior will basically be the same, but depending on the topology and what's going on, you could get very different results doing a RELEASE/NEW LEASE versus a true RENEW.

On the GUI version, OS X has a bug in its behavior where its RENEW is actually a REBIND. Again, this is probably going to get you the same results on many networks, but it's not a real RENEW. The difference between a RENEW and a REBIND is that a RENEW is a directed unicast to the original server that gave you the address asking for an extension on the list; a REBIND is a broadcast that you do after you don't get an answer on your RENEW (T1 has expired, and T2 has expired). "



[ Reply to This | # ]
Renewing DHCP lease fails with OS X Server, Apple PCI Ethernet, Time Warner cable modem
Authored by: dkallan on Mar 20, '07 01:52:15PM

Hi,

I have a Mac OS X Server (a dual-2GHz G5, now at 10.4.9) acting as a server, firewall and NAT router for my Time Warner Roadrunner service, connected through a Toshiba DAZ8823A cable modem. The built-in ethernet connects to the LAN, and the add-on Apple Gigabit Ethernet PCI card (revision 0x0002).

Everything works great, except that OS X Server must be rebooted in order to acquire a DHCP lease, and a lease cannot be renewed or rebound without another reboot.

When the machine starts up, it successfully acquires an address and configuration from the cable modem. Every 12-24 hours, when the lease expires (or if there is a network outage during the day), the machine is unable to renew a DHCP lease, and there is no internet connectivity.

  • I have tried the ifconfig up/down commands to deactivate and reactivate the interface (the lights visibly go out), I have tested the ipconfig set NONE/BOOTP/DHCP commands in various combinations, I have used the GUI to de/reactivate the interface, I have tried the GUI's Renew DHCP Lease button--all to no avail. I have done ifconfig down followed by ipconfig DHCP. In any combination, the result is the same: an active interface with no IPv4 inet address.
  • I have tried unplugging the cable modem, letting time pass, then plugging it back in. Same problem. Even if I have an active lease, attempting to renew it by any of the above methods results in no IPv4 inet address.
  • The only thing that has worked is to set a cron job to shutdown -r the machine every 12 or 24 hours. Needless to say, this is completely stupid and highly disruptive, but nothing else has worked.

Interestingly, the Apple Airport Extreme Base Station IS able to request and renew DHCP leases from the cable modem without problem. Unfortunately, the Airport does not handle NAT/ESP/GRE routing well enough to support running an IPSec VPN server, requiring me to use the OS X Server as the NAT/ipfw router.

I am at the end of my rope. Any ideas at all?



[ Reply to This | # ]
Renewing DHCP lease fails with OS X Server, Apple PCI Ethernet, Time Warner cable modem
Authored by: tonyy on Apr 27, '07 04:47:36AM
Unfortunately, the Airport does not handle NAT/ESP/GRE routing well enough to support running an IPSec VPN server, requiring me to use the OS X Server as the NAT/ipfw router.
Are you referring to the new Airport Extreme N here? I have Tiger Server VPN running as well behind that router and VPN seems to be working well.

[ Reply to This | # ]
Renewing a DHCP lease
Authored by: lange on Apr 25, '07 10:39:17AM

This may be a little late, but I may have found the problem in OS X Client 10.4.8 and 10.4.9 on an Intel Mac Pro. I was attempting to authenticate over the network with Kerberos and LDAP, but when the computer woke up from sleep there was no IP address. This also occurred on boot up. To fix the problem, I went to System Preferences, then to Network, then selected the ethernet card and selected Configure IPv6. Then I selected Off and Applied the change.

Good luck,
Ryan



[ Reply to This | # ]
Renewing a DHCP lease
Authored by: dkallan on May 20, '07 03:59:00PM
Are you referring to the new Airport Extreme N here? I have Tiger Server VPN running as well behind that router and VPN seems to be working well.

Nope, just the plain old Extreme B/G... the flying saucer. It is reassuring to read that you are able to run a VPN server behind the Extreme N. That makes me want to run out and buy one! Did you have to do anything special to make this setup work? Has anyone been able to get the OS X Server VPN Server working behind an 802.11b/g Airport Extreme?

Thanks for the comment, Tony.



[ Reply to This | # ]
Renewing a DHCP lease
Authored by: MacTipster on Jan 04, '12 03:37:54PM

How to do it with Mac OS X 10.6 and later? It is not possible to do as indicated:

"The 'normal' way involves the Network preference pane in the System Preferences application. Click on the "Show" pull-down menu and select either 'Network Port Configurations' or 'Active Network Ports,'..."

Besides, the Terminal commands do not seem to work.



[ Reply to This | # ]
Renewing a DHCP lease
Authored by: MacTipster on Jan 20, '12 09:24:54AM

It is possible to do it with Mac OS X 10.6 and later? Thanks.



[ Reply to This | # ]
Renewing a DHCP lease
Authored by: BiL Castine on Jan 22, '12 06:55:47PM
sudo ipconfig set en0 DHCP works for me on Mac OS X 10.7.2. just be sure you replace en0 with the identifier of the network interface you want to renew the lease on. If it's a stock configured MacBook Pro, MacBook or iMac, then en0 will be the Ethernet port and en0 will be the wifi port. to get the identifiers of the network ports, you can use System Profiler in the Apple menu.

[ Reply to This | # ]
Renewing a DHCP lease
Authored by: chymb on Jan 02, '13 05:23:40PM

I've added this as a separate hint since this one is so old now, but the command:

echo "add State:/Network/Interface/en0/RefreshConfiguration temporary" | sudo scutil

renews the lease in the same way as the System Preference Pane.
It works on 10.4+ (it may work on <10.4 but I don't have one to check)



[ Reply to This | # ]