Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to change my ip address from terminal in mac. So i used the following commands.

ifconfig en1
route add default

if i change the ip here. It is getting reflected in the terminal but the change is not reflected in the gui. As a result of which i am not even able to ping the gateway.

Is there some other way of changing ip address via terminal?

share|improve this question

migrated from Nov 14 '10 at 14:31

This question came from our site for professional and enthusiast programmers.

In OS X, the network interfaces are managed by configd based on the configurations defined in /Library/Preferences/SystemConfiguration/*. If you change the "live" settings with ipconfig and such, it won't show up in System Preferences, and configd is likely to overwrite them back to what it thinks the settings should be. So, rather than changing the live config, you should change the system settings and let configd apply the change. The simplest way to do this is with the networksetup command:

networksetup -setmanual "Ethernet"

Note that you need to specify the interface to configure by its service name (the one System Preferences shows; "Ethernet" in my example) rather than the unix device name (e.g. "en0"). Also, networksetup doesn't seem to understand CIDR notation ("/16"), so you need to give the full subnet mask.

share|improve this answer
sudo ifconfig en1 inet <desired IP address>
share|improve this answer

You must log in to answer this question.