Last active
January 8, 2018 07:05
-
-
Save notsobad/5d541739a3ebeced9da69196af741455 to your computer and use it in GitHub Desktop.
Add route table when you have both wi-fi and ethernet connected to different network.
This file contains 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 | |
# if ethernet DOES NOT connected, remove route table | |
ifconfig en6 | grep 'inet 10.200.' || { | |
echo cleanup | |
sudo route delete 10.0.0.0/8 10.200.33.1 | |
networksetup -setdnsservers Wi-Fi 114.114.114.114 | |
networksetup -setsearchdomains Wi-Fi '' | |
exit 0 | |
} | |
netstat -nr|awk '{if($1 == "10" && $2 == "10.200.33.1") print}' | grep 10.200.33.1 && { | |
echo "Alreay has the right route table" | |
exit 0 | |
} | |
sudo route add 10.0.0.0/8 10.200.33.1 | |
networksetup -setdnsservers Wi-Fi 10.200.2.1 | |
networksetup -setsearchdomains Wi-Fi 'notsobad.com' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment