Setup DNS on macos from command line
If you get to remotely manage mac users over ssh, the networksetup command is a great tool.
The full manual is here : https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/networksetup.8.html
Here’s how to setup a dns server:
- find the interface name
- your output would look similiar to this:
(1) Bluetooth DUN
(Hardware Port: Bluetooth DUN, Device: Bluetooth-Modem)
(Hardware Port: Ethernet, Device: en0)
(Hardware Port: AirPort, Device: en1)
3.choose the device you want to apply the dns settings to and run this command ( in this example were applying it to the AirPort interface ), change the google dns addresses to your preferred ones.
networksetup -setdnsservers AirPort 184.108.40.206 220.127.116.11
- verify your changes using :