Configure MAC OSX Network Interface from the Command Line

Configure MAC OSX Network Interface from the Command Line

By : -

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" 192.168.1.10 255.255.255.0 192.168.1.1

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

networksetup -getinfo "Ethernet"

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

networksetup -setdnsservers "Wi-Fi" 8.8.8.8 4.2.2.2
2 Comments

Leave a Reply

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