Skip to content

Instantly share code, notes, and snippets.

@realamirhe
Created July 26, 2023 11:11
Show Gist options
  • Select an option

  • Save realamirhe/3d6c9e8e60fd49ddee259ceea1349c94 to your computer and use it in GitHub Desktop.

Select an option

Save realamirhe/3d6c9e8e60fd49ddee259ceea1349c94 to your computer and use it in GitHub Desktop.
mac dns setter from terminal
function dns {
if [[ $1 == "shecan" ]]
then
networksetup -setdnsservers Wi-Fi 178.22.122.100 185.51.200.2
echo "[Shecan] dns has been set accrodingly"
elif [[ $1 == "radar" ]]
then
networksetup -setdnsservers Wi-Fi 10.202.10.10 10.202.10.11
echo "[Radar game] dns has been set accrodingly"
elif [[ $1 == "electro" ]]
then
networksetup -setdnsservers Wi-Fi 78.157.42.100 78.157.42.101
echo "[Electro Team] dns has been set accrodingly"
elif [[ $1 == "403" ]]
then
networksetup -setdnsservers Wi-Fi 10.202.10.202 10.202.10.102
echo "[403.online] dns has been set accrodingly"
elif [[ $1 == "asia" ]]
then
networksetup -setdnsservers Wi-Fi 194.36.174.161 178.22.122.100
echo "[asiatech] dns has been set accrodingly"
elif [[ $1 == "cloud" ]]
then
networksetup -setdnsservers Wi-Fi 1.1.1.1 1.0.0.1
echo "[Cloudflare] dns has been set accrodingly"
else
networksetup -setdnsservers Wi-Fi "empty"
echo "dns has been removed."
fi
}
@realamirhe
Copy link
Author

Set:

dns shecan

Verify:

cat /etc/resolv.conf

@realamirhe
Copy link
Author

Robust version of the following bash function
https://github.com/Amirali-Bagheri/mac-dns-changer/blob/main/dns.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment