Renew a Mac's DHCP Lease Via Terminal

Being a long-time (and still part-time) Windows user, I’ve spent many a not-so-happy second typing the following:

> ipconfig /release
> ipconfig /renew

Today, though, I made a few changes to secure my network and needed to renew the DHCP lease of my Mac. Usually, I’m sitting in front of the laptop so I can just use the System Preferences GUI, but not today. Today I had to remote in so I only had the command line available and I realized that I had no idea how to map the Windows commands above to the Mac terminal. Mostly for the sake of posterity:

$ sudo ifconfig set en0 BOOTP
$ sudo ifconfig set en0 DHCP

In typical Unix fashion, there’s no output to indicate that succeeded or did anything at all, for that matter, but it seems to do the trick.

Subscribe4 Comments on Renew a Mac's DHCP Lease Via Terminal

  1. jcrowgey said...

    should be $ifconfig

  2. Rob Wilkerson said...

    Yep, for the second code sample, you’re absolutely right. Typo. I’ve made the adjustment in the post. Thanks for pointing that out.

  3. murga said...

    hey,
    i think it should be ipconfig.

    if i try to renew the adress with ifconfig I get an error

    sh-3.2# ifconfig set en0 DHCP
    ifconfig: interface set does not exist

    so if i use ipconfig everything works fine.

  4. tje210 said...

    so i find going through all those menus tiresome when i need to renew my dhcp lease, so i was looking for a way to do it via terminal. found this website… and i executed those commands. checked it for effectiveness in the GUI menu, and immediately freaked when it said i had no IP address!! however, it seems i can still browse. ifconfig tells me i do have an ip, so that’s cool… but can anyone tell me why the GUI (and iStat) won’t tell me my ip?