Skip to content

Instantly share code, notes, and snippets.

@eaorak
Created March 30, 2016 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eaorak/59c739b2f1ffe6e3df26d38177a47bbc to your computer and use it in GitHub Desktop.
Save eaorak/59c739b2f1ffe6e3df26d38177a47bbc to your computer and use it in GitHub Desktop.
##############################################################################
# This script can be used for setting DNS on Mac computers from command line.
# It either sets dns to google dns servers when no parameter is provided
# or empties DNS settings when called with 'none'.
##################################################################### eaorak #
#!/bin/bash
dns='8.8.8.8 8.8.4.4'
empty='empty'
if [ "$1" = "none" ]; then
dns=$empty
fi
networksetup -setdnsservers Wi-Fi $dns
networksetup -getdnsservers Wi-Fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment