
For example, this would set OpenDNS for the first two DNS servers, and Google DNS as the third fallback: You can set multiple DNS servers if desired, which will enable fallback in the event the first or second server is unreachable. Networksetup -setdnsservers Wi-Fi 8.8.8.8 Networksetup -setdnsservers (Network Service) (DNS IP)įor example, to set a Mac with wi-fi to Google DNS of 8.8.8.8 the syntax would be: You’ll use the -setdnsservers flag, point it at the network service, and then include the DNS IP, this may look like the following: The networksetup command is available in all vaguely modern versions of Mac system software. How to Set DNS Servers from the Command Line of OS X with networksetup

While networksetup has many advanced and complex uses, setting DNS is actually quite easy.


To change DNS settings from the command line of OS X, you’ll be using the ever-useful ‘networksetup’ command.
