November 28, 2013

Renew DHCP from the Terminal

My MacBook Pro’s internet has been acting up every time it wakes from sleep. It loses the network configuration and I get the WiFi with exclamation point icon.

Without time for real debugging, I noticed that clicking Renew DHCP Lease under System Preferences › Network › Advanced… › TCP/IP would fix the issue. However, getting there after each wake-up was very ungeeky of me.

A quick search turned up a way to do it from the terminal, then just open up ~/.bash_profile, and add:

alias dhcp-renew='echo "add State:/Network/Interface/en0/RefreshConfiguration temporary" | sudo scutil'

Now, I do a ⌘+tab for the always open terminal window, type in dhcp-renew and password — if I have not authenticated in a while — and boom, all is right with the internet.

Menubar Internet and TerminalMenubar Internet and Terminal

I’m attributing this to a Mavericks bug[1], and hope that a 10.9.1 squashes this, but in the meantime it’s a quick fix that can be useful in other situations.

  1. @tukeke told me he’s suffering this on his brand new MBP also.  ↩︎

geek tidbit

Previous post
I’m Back. What a year. At least in the analog world. Mucho changes, and still more to come. But now I’m back, for the nth time. I missed you too
Next post
Ping Time Interval Another duh tip for the terminal. But if you want to increase the wait time between pings to 60 seconds, just: Why? well, let’s just say that my