Configure MAC OSX Network Interface from the Command Line

Command line network configuration for the MAC is quite a bit different when compared to Linux or Unix. The networksetup command is used instead of ifconfig to configure devices.

The first step is to get a list of all network services – these are really physical and virtual devices, VPNs, etc..

networksetup -listallnetworkservices

The next step is to get the current settings for the network service that you might want to configure – the following example is using the service “Ethernet” and is enclosed in quotes as some of the services have spaces in the names:

networksetup -getinfo "Ethernet"

To configure an interface manually, use something like the following:

networksetup -setmanual "Ethernet"

Confirm that the settings are correct by issuing the getinfo command once more:

networksetup -getinfo "Ethernet"

2 thoughts on “Configure MAC OSX Network Interface from the Command Line”

  1. Setup DNS servers for a specific interface named “Wi-Fi”:

    networksetup -setdnsservers "Wi-Fi"

Leave a Reply

Your email address will not be published. Required fields are marked *