Skip to content

Instantly share code, notes, and snippets.

@Valthoron
Created April 8, 2014 10:39
Show Gist options
  • Save Valthoron/10108457 to your computer and use it in GitHub Desktop.
Save Valthoron/10108457 to your computer and use it in GitHub Desktop.
AppleScript that presents a list of public domain name servers to the user, sets the Wi-Fi DNS addresses according to selection, finally clears the DNS cache.
on run
choose from list {"<Default>", "OpenDNS", "Google Public DNS", "Norton DNS for Home", "Comodo Secure DNS", "Neustar DNS Advantage", "Verizon / Level 3"} with prompt "Please select a DNS service:" with title "Wi-Fi DNS Selector" without multiple selections allowed and empty selection allowed
if the result is not false then
if item 1 of the result is "<Default>" then
do shell script "networksetup -setdnsservers Wi-Fi Empty" with administrator privileges
do shell script "dscacheutil -flushcache" with administrator privileges
else if item 1 of the result is "OpenDNS" then
do shell script "networksetup -setdnsservers Wi-Fi 208.67.222.222 208.67.220.220" with administrator privileges
do shell script "dscacheutil -flushcache" with administrator privileges
else if item 1 of the result is "Google Public DNS" then
do shell script "networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4" with administrator privileges
do shell script "dscacheutil -flushcache" with administrator privileges
else if item 1 of the result is "Norton DNS for Home" then
do shell script "networksetup -setdnsservers Wi-Fi 198.153.192.50 198.153.194.50" with administrator privileges
do shell script "dscacheutil -flushcache" with administrator privileges
else if item 1 of the result is "Comodo Secure DNS" then
do shell script "networksetup -setdnsservers Wi-Fi 8.26.56.26 8.20.247.20" with administrator privileges
do shell script "dscacheutil -flushcache" with administrator privileges
else if item 1 of the result is "Neustar DNS Advantage" then
do shell script "networksetup -setdnsservers Wi-Fi 156.154.70.1 156.154.71.1" with administrator privileges
do shell script "dscacheutil -flushcache" with administrator privileges
else if item 1 of the result is "Verizon / Level 3" then
do shell script "networksetup -setdnsservers Wi-Fi 4.2.2.1 4.2.2.2 4.2.2.3 4.2.2.4 4.2.2.5 4.2.2.6" with administrator privileges
do shell script "dscacheutil -flushcache" with administrator privileges
end if
end if
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment