Skip to content

Instantly share code, notes, and snippets.

@loosebits
Last active August 29, 2015 14:09

Revisions

  1. loosebits revised this gist Feb 1, 2015. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion vpn.sh
    Original file line number Diff line number Diff line change
    @@ -11,9 +11,10 @@ fi

    GATEWAY="$(route -n get 8.8.8.8 | grep gateway | awk '{print $2}')"
    echo "Detected gateway to be $GATEWAY"
    networksetup -connectpppoeservice $PPPOE
    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}'`
  2. loosebits revised this gist Nov 10, 2014. 1 changed file with 7 additions and 4 deletions.
    11 changes: 7 additions & 4 deletions vpn.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,7 @@
    #! /bin/bash
    PPPOE=HCSC
    IFNAME=utun0
    SUBNET="10.0.0.0/8"
    if [ $(id -u) != "0" ]
    then
    echo "Running using sudo.."
    @@ -7,10 +10,10 @@ then
    fi

    GATEWAY="$(route -n get 8.8.8.8 | grep gateway | awk '{print $2}')"
    echo "Detected gateway to be $gateway"
    networksetup -connectpppoeservice HCSC
    while ! ifconfig | grep utun0 > /dev/null; do
    echo "Detected gateway to be $GATEWAY"
    networksetup -connectpppoeservice $PPPOE
    while ! ifconfig | grep $IFNAME > /dev/null; do
    sleep .2
    done
    route change default $GATEWAY
    route add -net 10.0.0.0/8 `ifconfig utun0 | grep inet | awk '{print $2}'`
    route add -net $SUBNET `ifconfig $IFNAME | grep inet | awk '{print $2}'`
  3. loosebits revised this gist Nov 10, 2014. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions vpn.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,11 @@
    #! /bin/bash
    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"
    networksetup -connectpppoeservice HCSC
  4. loosebits created this gist Nov 10, 2014.
    9 changes: 9 additions & 0 deletions vpn.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #! /bin/bash
    GATEWAY="$(route -n get 8.8.8.8 | grep gateway | awk '{print $2}')"
    echo "Detected gateway to be $gateway"
    networksetup -connectpppoeservice HCSC
    while ! ifconfig | grep utun0 > /dev/null; do
    sleep .2
    done
    route change default $GATEWAY
    route add -net 10.0.0.0/8 `ifconfig utun0 | grep inet | awk '{print $2}'`