Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

ifconfig en1 192.168.110.1/16
route add default 192.168.110.1

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 stackoverflow.com Nov 14 '10 at 14:31

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

2 Answers 2

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" 192.168.110.1 255.255.0.0 192.168.110.1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.