Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Mac change ip address from terminal

Writer Sophia Terry

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?

0

2 Answers

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.

sudo ifconfig en1 inet <desired IP address>

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy