Changing local IP address with networksetup command on OSX


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

    This assumes the following:

    • netmask is a /24 (254 hosts)
    • the router/gateway is the "common"
    • 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
  • Related Question