Skip to content

Instantly share code, notes, and snippets.

@fangel
Created June 17, 2011 07:24
Show Gist options
  • Save fangel/1031009 to your computer and use it in GitHub Desktop.
Save fangel/1031009 to your computer and use it in GitHub Desktop.
#!/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