Skip to content

Instantly share code, notes, and snippets.

@mstade
Last active December 20, 2015 19:00
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 mstade/aa273c6227ebb660fd45 to your computer and use it in GitHub Desktop.
Save mstade/aa273c6227ebb660fd45 to your computer and use it in GitHub Desktop.
unblock-us toggle
# Unblock-US toggler
function unblock-us() {
local status="${1}"
local default="Wi-Fi"
local service="${2:-${default}}"
if [[ "${status}" == "on" ]]; then
local dns=(208.122.23.23 208.122.23.22)
elif [[ "${status}" == "off" ]]; then
local dns="empty"
else
local IFS=$'\n'
local svclist=($(networksetup -listallnetworkservices))
cat<<-USAGE
usage: unblock-us on|off [<service>]
commands:
on Enables the Unblock-US DNS.
off Disables the Unblock-US DNS.
arguments:
<service> The service used for the Unblock-US DNS;
defaults to '${default}' if not specified.
services:
$(printf ' %s\n' "${svclist[@]}")
USAGE
printf "${status:+\n"error: invalid option '${status}'"\n}"
return 1
fi
sudo networksetup -setdnsservers ${service} ${dns[@]}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment