_ | | ___ __| |_ __ ___ / __|/ _` | '_ \/ __| \__ \ (_| | | | \__ \ |___/\__,_|_| |_|___/
A command-line DNS switcher for macOS.
You could do:
Apple Menu -> System Preferences -> Network -> Wi-Fi -> Advanced -> DNS -> [+]
and then manually type in your new DNS servers like a chump. Or you could just type:
$ sdns switch google
and have it done automatically.
Caveat 1: At the moment sdns
only works with the Wi-Fi interface.
Caveat 2: You'll be asked to enter your user password to make any DNS settings changes. Don't be alarmed by this, it's perfectly normal.
Caveat 3: If you don't have networksetup
installed for some reason (the absence of which would be pretty freaky if you're on macOS), things will not go well for you.
To double-check: $ which networksetup
. You should see /usr/sbin/networksetup
.
This is a Crystal app. Until I make a proper release, your best bet is to install Crystal via Homebrew, download this source code, compile, and install it yourself.
You'd like to try it before installing it, or want to change the source:
cd ./sdns
`make build`, `make debug`, or `make run`
Check the Makefile for details on the differences between each.
You don't care about the source or mucking about with it, you just want to use this app to switch your DNS. You just need the app installed:
cd ./sdns
make install
The installation process:
- compiles the excutable binary
- copies that binary to
/usr/local/bin
- copies a
.sdns.yaml
config file to your home directory
Still less effort than clicking through the Network system pref to do things.
Similar process:
cd ./sdns
make uninstall
The uninstallation process:
- removes the binary from
/usr/local/bin
- removed the
.sdns.yaml
file from your home directory
First, ensure that .sdns.yaml
is in your home directory ($ ls -al ~ | grep sdns
).
This source comes with one configured for Google, OpenDNS, and UnblockUs that will be written to that location the first time you run the app. Extend that at your leisure.
sdns
supports the following commands:
$ sdns current
Displays your current DNS settings. If you have custom settings configured, it'll display those:
google:
8.8.8.8
8.8.4.4
If you don't yet have any custom settings configured, you'll see this message:
There aren't any DNS Servers set on Wi-Fi.
$ sdns default
Switched your DNS settings back to their default settings, which is likely whatever your router or ISP provide.
In other words, it deletes your custom settings.
$ sdns flush
Flushes your DNS cache (works on Sierra; may not yet work in earlier OS X releases).
$ sdns help
Displays help documentation describing all the available commands.
$ sdns list
Displays a table of all the possible DNS settings you cand switch to. Available out of the box are Google, OpenDNS, and UnblockUs.
$ sdns switch 1
or
$ sdns switch google
Switches your DNS settings to the specified provider.
You can also use:
$ sdns switch empty
to delete any custom settings. This is effectively the same as ./sdns default
.
$ sdns --version
Displays the current app version.
The project is available as open source under the terms of the MIT License.