Release/renew IP address via Terminal in OS X
Olivia Zamora
I am looking to release and renew my IP address in OS X 10.4 (Tiger) using Terminal. Essentially, I need the OS X equivalent of Windows':
C:\\> ipconfig /release
C:\\> ipconfig /renewHowever, I need the interface to remain active during this process, so using ifconfig down/up will not work.
I believe I can clear the IP address with ifconfig <interface> delete, but I'm not sure how to get the DHCP client to reassign the address. An article from 2002 suggests using set dhcp, but Apple's ifconfig man page does not include this information.
4 Answers
sudo ipconfig set en0 BOOTP
sudo ipconfig set en0 DHCPShould do it.
Sources: 0
I find that the commands
ipconfig set <interface> BOOTP
ipconfig set <interface> DHCPdo 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.
2If 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 AutomaticYou 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…".
I was able to release/renew the IP address using
sudo ipconfig set en0 BOOTP <return>
sudo ipconfig set en0 DHCP <return>But now I can't access screen sharing over Ethernet using the built-in VNC. I can still access it over Wi-Fi from my phone.
2