Skip to content

Instantly share code, notes, and snippets.

@neklaf
Last active July 19, 2022 09:44
Show Gist options
  • Save neklaf/02ee06044e7e23e251572479e1684c9b to your computer and use it in GitHub Desktop.
Save neklaf/02ee06044e7e23e251572479e1684c9b to your computer and use it in GitHub Desktop.
Modifying DNS on macOS from command line

A non persistent way across reboots to change the DNS:

# scutil
> open
> d.init
> d.add ServerAddresses * 8.8.8.8 9.9.9.9
> set State:/Network/Service/PRIMARY_SERVICE_ID/DNS
> quit

To check the change:

$ scutil --dns

To find a key that we want to change:

$ scutil
> list
...

Other command to change DNS information is:

# networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment