Release/renew IP address via Terminal in OS X

sudo ipconfig set en0 BOOTP
sudo ipconfig set en0 DHCP

Should do it.


Sources:
  • macosxhints.com
  • itnetcentral.com

I find that the commands

ipconfig set <interface> BOOTP 
ipconfig set <interface> DHCP

do accomplish releasing the interfaces IP, but won't renew it. This behavior might be explained because I'm working on a MACBook Air. However, I've also tried this on a MacBook Pro with the same outcome. A quick perusal of networksetup's man page reveals two sister commands to the ones for ipconfig. These commands are

networksetup -setbootp <network service name>
networksetup -setdhcp <network service name>

where is the name seen in the network settings status pane. If you open the network settings you can watch this command work by watching the "Configure IPv4" option change. Note, to save on typing I excluded the sudo from all my commands, and of course if your system requires elevated priveleges to execute commands you should use "sudo" on the front of the commands listed in this answer. Hope this saves someones the hair pulling and fuming I experienced looking for such a simple command.


If you need to do this without having sudo privileges, then the easiest way is to create a new location, let's call it "DHCP", and then change to it, and back again… This also causes Mac OS X to reconfigure the networking. The commands needed are:

scselect DHCP
scselect Automatic

You can create a new network location from the network preference setting panel, select the dropdown at the top that says "Automatic" and then "Create New…".