How to Renew a DHCP Lease in Mac OS X
DHCP stands for Dynamic Host Configuration Protocol, and is commonly used to configure network devices so they can communicate with one another. Typically you’ll have a DHCP server (like a wireless router), and client machines on the local network (like a Mac, iPhone, PC, etc) that pull a dynamically assigned local IP address from that server.
This is all well and good and usually functions just fine, but sometimes you need to renew a DHCP lease, which basically means you’ll be retrieving a new IP address and routing data from the DHCP server. This is a common trick for troubleshooting network issues, and can be helpful when resolving problems with internet connectivity when a wi-fi connection has been determined to be stable, or when a machine on the network can’t access the outside world after power-cycling a broadband modem or router.
Renew DHCP Lease from OS X System Preferences
This is the easiest way to renew a DHCP lease from Mac OS X:
- Pull down the Apple menu and choose “System Preferences”
- Click on “Network” and select the currently active network connection from the left side list, usually this will have a green icon next to it and say ‘Connected’
- Click on the “Advanced” button in the lower right corner
- Select the “TCP/IP” tab and then select the “Renew DHCP Lease” button
- After the IP, subnet, and router has repopulated with new IP information, click “OK” and exit out of System Preferences
Often renewing a DHCP lease means the Mac will end up with a different local IP address than it had before, though sometimes you will end up with the same one. If the reason you are renewing DHCP is to try and get a new IP address but the router continues to stubbornly assign the same LAN IP over and over again, consider setting a static IP instead by configuring DHCP with manual addresses.
Another approach, though more advanced, is to renew DHCP by way of the command line. This is typically best used by advanced users, but it can also be helpful for remote troubleshooting if you can only SSH into a remote Mac and something like Screen Sharing is not available to you. The other obvious advantage with a command line approach is possibility of using the lease renewal in a script or as part of an automated task within cron.
Renewing a DHCP Lease from the Command Line
There are two different ways to renew the DHCP lease from the OS X command line. The first approach uses the ever useful ipconfig tool:
sudo ipconfig set en0 DHCP
When using ipconfig, be sure to use the proper interface address otherwise you may run into other problems, or find nothing changes at all. You can retrieve interface data by using ipconfig to pull current DHCP information like so:
ipconfig getpacket en1
Ran successfully, you will find DHCP server information, client IP, lease time, the subnet mask, router IP, and DNS servers, the tail of the command should look something like this:
If running that command returns nothing, then you are looking at the wrong interface. Typically en0 is the default wi-fi interface on MacBook Air and newer MacBook Pro models, but it is often en1 on Macs with physical ethernet ports.
The ipconfig method will interrupt the current network connection, whereas resetting through Network Preferences does not. You can refresh DHCP without interruption from the command line by using the following scutil command provided by a MacWorld user:
echo "add State:/Network/Interface/en0/RefreshConfiguration temporary" | sudo scutil
You can verify the changes took place by using the aforementioned ipconfig command again:
ipconfig getpacket en0
Again, be sure to use the appropriate network interface for your hardware: en1 or en0.
Each method outlined here will work in virtually every version of Mac OS X, from the old versions to the new.
Finally, if you’re troubleshooting network wide issues on all devices on a LAN, you can also renew a DHCP lease from iOS and get new local IP addresses on iPhones, iPods, and iPads.
This does not work for me from a cron job. Works fine from the CLI directly, but not from Cron.
Ok, so I followed the instructions and hit the “ Renew DHCP Lease” button.
My Wi-Fi is not connected. I am using Ethernet. I am using Air Port Extreme. Why can I not connect Wi-Fi?