Skip to content

Instantly share code, notes, and snippets.

@wen-long
Created February 3, 2015 13:51
Show Gist options
  • Save wen-long/f6a5b7af7ccef86f1f2b to your computer and use it in GitHub Desktop.
Save wen-long/f6a5b7af7ccef86f1f2b to your computer and use it in GitHub Desktop.
#! /bin/zsh
if [ $UID -ne 0 ]; then
echo "Superuser privileges are required to run this script."
echo "e.g. \"sudo $0\""
exit 1
fi
OLD_IFS=$IFS
IFS=$'\n'
arr=(`networksetup -listallnetworkservices`)
len=${#arr[@]}
for ((i=2;i<$len;i++));do
networksetup -setdnsservers "$arr[i]" 127.0.0.1
done
IFS=OLD_IFS
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment