Created
June 17, 2011 07:24
-
-
Save fangel/1031009 to your computer and use it in GitHub Desktop.
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/sh | |
# Then try and figure out which gateways to use | |
DEFAULT_GATEWAY=`netstat -rn | grep default | grep -v utun | head -n1 | awk '{print $2}'` | |
VPN_GATEWAY=`netstat -rn | grep utun | grep -v default | head -n1 | awk '{print $1}'` | |
if [ -z "$VPN_GATEWAY" ]; then | |
echo "It appears you arent on VPN. FYI, your gateway is $DEFAULT_GATEWAY." | |
exit -1 | |
else | |
echo "Using $DEFAULT_GATEWAY for internet, $VPN_GATEWAY for VPN." | |
fi | |
route -q delete default | |
route -q add default $DEFAULT_GATEWAY | |
route -q add -net 10.0.6 $VPN_GATEWAY | |
route -q add -net 10.254 $VPN_GATEWAY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment