Set IP Address from the Mac Command Line

Sep 1, 2010 - 16 Comments

set ip address mac command line
The quickest way to set your IP address from the command line is to 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.

You can specify an IP address to set via the command line with the following:
sudo ipconfig set en1 INFORM 192.168.0.150

You can also get a new IP address from a DHCP server by bringing down the interface and starting it back up again:
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.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: David Mendez in Command Line, Mac OS X, Tips & Tricks

16 Comments

» Comments RSS Feed

  1. Ed says:

    “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?

  2. Borg says:

    Hi,
    ipconfig – it’s a command from the windows, or something I don’t know. Please correct me if I’m wrong ;)

  3. eab3 says:

    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.

  4. […] 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 […]

  5. […] 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. […]

  6. According to the Mac OS X man page, Using ipconfig with INFORM requires 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….

  7. lakitu64 says:

    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.

  8. sirio says:

    i get this problem with my MAC.. should i do that ..?? Another device on the network is using your computer IP address

  9. Andrew Hutton says:

    I am trying to follow the above steps and get this”

    usage: set

    Can anyone tell me what to do please?

  10. aub says:

    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?

  11. Matt says:

    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

  12. BooHoo says:

    This has caused far more problems than it has solved – NOT recommended

  13. BooHoo says:

    Problems being complete loss of wifi symbol and internet UNLESS I run that command, each time I turn it on.

    How do I undo?

  14. James says:

    So very helpful. Thank you. It says I am not connected and there is an issue with the WIFI but internet is working

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates