-
-
Save rhybroy/48e03ca39e1f4645aec4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Please run this shell with "sudo ..." | |
SERVICE=Wi-Fi | |
# You could change the service. List all network services via: | |
# networksetup -listallnetworkservices | |
echo "" | |
echo "Current DNS on ${SERVICE}:" | |
networksetup -getdnsservers ${SERVICE} | |
echo "======================" | |
echo "0 . Default (Empty)" | |
echo "1 . google DNS" | |
echo "2 . ali DNS" | |
echo "3 . openDNS" | |
echo "4 . v2ex" | |
echo "5 . 114" | |
echo "Choose new DNS on ${SERVICE} :" | |
read newDNS | |
case $newDNS in | |
0) | |
# default | |
networksetup -setdnsservers ${SERVICE} Empty;; | |
1) | |
# google DNS | |
networksetup -setdnsservers ${SERVICE} 8.8.8.8 8.8.4.4;; | |
2) | |
# ali DNS | |
networksetup -setdnsservers ${SERVICE} 223.5.5.5 223.6.6.6;; | |
3) | |
# openDNS | |
networksetup -setdnsservers ${SERVICE} 208.67.222.222 208.67.220.220 208.67.222.220 208.67.220.222;; | |
4) | |
# v2ex | |
networksetup -setdnsservers ${SERVICE} 199.91.73.222 178.79.131.110;; | |
5) | |
# 114 | |
networksetup -setdnsservers ${SERVICE} 114.114.114.114 114.114.115.115;; | |
*) | |
echo " do nothing... ";; | |
esac | |
echo "======================" | |
echo "Current DNS on ${SERVICE}:" | |
networksetup -getdnsservers ${SERVICE} | |
echo "" | |
exit 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment