Changing local IP address with networksetup command on OSX

Network

My computer routinely receives connection from another host in the local network. However, the router changes its ip address quite frequently, and maybe netsh's equivalent, networksetup, can help?

Best Answer

  • The command to manually set an IP address is:

    networksetup -setmanual Ethernet 192.168.0.6 255.255.255.0 192.168.0.1
    

    This assumes the following:

    • netmask is a /24 (254 hosts)
    • the router/gateway is the "common" 192.168.0.1
    • Your interface is Ethernet

    You will need to adjust your settings accordingly. To get a list of network services (interfaces), you can issue the command:

    networksetup -listallnetworkservices