Set IP Address from the Mac Command Line
The quickest way to set your IP address from the command line is to use the versatile and powerful ipconfig utility, which is bundled directly with Mac OS X. We’ll show you how to set an IP address with ipconfig by retrieving one from a DHCP server, and also demonstrate how to set a specific IP address in OS X if you wish to determine a static address for a Mac.
Starting with setting an IP address from a DHCP connection, issue the following command in the Terminal:
sudo ipconfig set en1 DHCP
This will renew your DHCP lease and you will be issued a new IP address from the DHCP server. FYI: en1 is generally wireless/airport, en0 is generally ethernet.
You can check that the IP is set by getting your current IP address from the command line with:
ipconfig getifaddr en1
Doing this before and after will insure you have a new IP.
How to Set a Specific IP Address via Terminal in OS X
You can specify an IP address to set via the command line with the following:
sudo ipconfig set en1 INFORM 192.168.0.150
This allows the user to set a determined static IP manually that won’t change, unless it has been overwritten by a new IP or a new IP has been specified.
Another approach is to bring the networking interface off and on again. This works to set an IP address from a DHCP server by bringing down the interface and starting it back up again, refreshing the IP:
sudo ifconfig en1 down ; sudo ifconfig en1 up
Note: for whatever reason, when you are setting the IP address manually via the command line the Mac OS X Network Preferences doesn’t necessarily catch up to the changes. Do not be surprised if the Network preference pane is telling you that you “Airport does not have an IP address and cannot connect to the Internet.” when in fact, you do have one and you are online. You can verify that you are connected to the LAN or internet by using the ping command.
Hi, so i am trying to change the manual ip to dhcp
and do my work that is not secure and change back to manual.
what would be the command for that. its for a work enviorment working on a secure lan line. Please advise the command.
I appreciate your help
Worked well for me, thanks
This was the only thing to help! Thanks so much!
When I enter sudo ipconfig set en1 DHCP, I get password:[a key icon] Nothing entered shows up, despite typing. three times and you’re out. I have OS Sierra If you’re still monitoring, would appreciate a suggestion, thank you!
Hey David, the terminal doesn’t allow you to see the password as you type it, this is a security precaution and default to all unix environments (Mac OS included) anytime you use ‘sudo’ or otherwise authenticate, whether for setting an IP address or otherwise. But once you get the password prompt, type it anyway and hit return, and it will work.
A bit more is explained here on this matter:
When I type the sudo command nothing happens. I don’t even get an error message.
So very helpful. Thank you. It says I am not connected and there is an issue with the WIFI but internet is working
Problems being complete loss of wifi symbol and internet UNLESS I run that command, each time I turn it on.
How do I undo?
This has caused far more problems than it has solved – NOT recommended
I did this in order to try and fix the my IP address is being used by another computer. Doing this now has my wifi as self-assigned (I didn’t do the self assign step) and I can’t get it to go to my regular IP address. Renew won’t do anything the only way to get a connection is to now manually put in my IP address and change the last 2digits. I just want to go back to normal so it doesn’t say self – assigned ip
I typed the command into terminal but now under my system preferences > network > advanced > TCP/IP > it says using DHCP .. but it does not state below which IPv4 address I am using.. why is this? is the permanent?
I am trying to follow the above steps and get this”
Can anyone tell me what to do please?
i get this problem with my MAC.. should i do that ..?? Another device on the network is using your computer IP address
I get this message when I try to do use the “sudo ipconfig set en1 INFORM 192.168.0.104” command:
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type “man sudo” for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Yes that is a message telling you that the sudo command is super user privileges and that it needs your password.
According to the Mac OS X man page, Using
INFORMrequires the use of an IP address and an explicit subnet mask. However, sadly, I’ve found that INFORM doesn’t work as advertised.
Have you actually tried this out and found that it worked? Using
ipconfig…INFORM, have you ever actually set an IP address statically and yet actually received DHCP option information, like DNS settings, that stuck?
In my experience, at least on Mac OS X 10.6.5, using
INFORM works exactly like setting
MANUAL and doesn't actually use DHCP to set any of the other networking options. :(
Also, what's with the "Renew DHCP Lease" button disappearing in the System Preferences Networking preference pane GUI when "Use DHCP with manual address" is selected? Grr….
Crud. Pardon my formatting error.
[…] The other command line option is to use: ipconfig getifaddr en1 which reports back only your en1 (usually wireless) IP address. You can change this to en0 for wired/ethernet too. I have heard ipconfig is not supported in all versions of Mac OS X so I did not recommend this as the first choice. However, using ipconfig you can also set your IP address from the command line. […]
[…] a pain depending on your access to the router itself. If resetting the router is a no go, you can renew your DHCP lease in Mac OS X either through the command line (as the linked article shows) or through the Network settings […]
ipconfig is a mac os x command-line utility for manipulating DHCP leases, including the DHCP with manual address (which is the INFORM option).
/usr/sbin/networksetup will do all this and more. Think of networksetup as a command-line equal to Network Preferences.
ipconfig – it’s a command from the windows, or something I don’t know. Please correct me if I’m wrong ;)
“sudo ipconfig set en1 INFORM 192.168.0.150” – is this then permanent, i.e. the equivalent of manually setting it in the Network pref pane?
Here is my input
Another input option u can set en0 eth0t o the command..