Skip to content

Instantly share code, notes, and snippets.

@hoangthienan
Last active July 31, 2019 18:55
Show Gist options
  • Save hoangthienan/16228f894a814024629067faf20ffbc7 to your computer and use it in GitHub Desktop.
Save hoangthienan/16228f894a814024629067faf20ffbc7 to your computer and use it in GitHub Desktop.
Change DNS from Command Line of macOS

How to Set DNS Servers from the Command Line of macOS with networksetup

For example, to set a Mac with wi-fi to Google DNS of 8.8.8.8 the syntax would be:

networksetup -setdnsservers Wi-Fi 8.8.8.8

You can set multiple DNS servers if desired,

networksetup -setdnsservers Wi-Fi 208.67.222.222 208.67.220.220 8.8.8.8

How to Clear All DNS Servers with networksetup

networksetup -setdnsservers Wi-Fi Empty

Checking DNS Settings with networksetup

networksetup -getdnsservers Wi-Fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment