Last active
August 29, 2015 14:09
-
-
Save loosebits/9418c55119a537f0ab66 to your computer and use it in GitHub Desktop.
VPN/Routing script
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 | |
PPPOE=HCSC | |
IFNAME=utun0 | |
SUBNET="10.0.0.0/8" | |
if [ $(id -u) != "0" ] | |
then | |
echo "Running using sudo.." | |
sudo "$0" "$@" | |
exit $? | |
fi | |
GATEWAY="$(route -n get 8.8.8.8 | grep gateway | awk '{print $2}')" | |
echo "Detected gateway to be $GATEWAY" | |
scutil --nc start $PPPOE | |
while ! ifconfig | grep $IFNAME > /dev/null; do | |
sleep .2 | |
done | |
sleep 1 | |
route change default $GATEWAY | |
route add -net $SUBNET `ifconfig $IFNAME | grep inet | awk '{print $2}'` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Grabs the default route, connects to the VPN, waits for the connection and then splits the routing