sdns v0.2.0

A command-line DNS switcher for macOS: 'sdns switch google'.
         _           
        | |          
 ___  __| |_ __  ___ 
/ __|/ _` | '_ \/ __|
\__ \ (_| | | | \__ \
|___/\__,_|_| |_|___/

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.


Caveats

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.

auth dialog

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.

Installation

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.

Installing for development

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.

Installing the binary

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.

Uninstalling the binary

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

Usage

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:

current

$ 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.

default

$ 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.

flush

$ sdns flush

Flushes your DNS cache (works on Sierra; may not yet work in earlier OS X releases).

help

$ sdns help

Displays help documentation describing all the available commands.

list

$ 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.

switch

$ 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.

version

$ sdns --version

Displays the current app version.

License

The project is available as open source under the terms of the MIT License.

Repository

sdns

Owner
Statistic
  • 4
  • 0
  • 2
  • 0
  • 2
  • about 7 years ago
  • February 13, 2017
License

Links
Synced at

Sat, 04 May 2024 08:44:11 GMT

Languages