Skip to content

Instantly share code, notes, and snippets.

@davidpelaez
Created April 19, 2013 03:55
Show Gist options
  • Select an option

  • Save davidpelaez/5418040 to your computer and use it in GitHub Desktop.

Select an option

Save davidpelaez/5418040 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Script which handles the routing issues as necessary for pppd.
# When the ppp link comes up, this script is called with the following
# parameters:
# $1 the interface name used by pppd (e.g. ppp3)
# $2 the codey device name
# $3 the codey device speed
# $4 the local IP address for the interface
# $5 the remote IP address
# $6 the parameter specified by the 'ipparam' option to pppd
#
log=/Users/David/ppp.log
$stamp=$(date)
echo $stamp >> $log
echo $1 > $log
## Routing setup for VPN
# Array of hosts to route for
# These are the domain names and IP addresses that will be accessed through the VPN
VPN_ROUTE_FOR_HOSTS=(172.19.200.15 10.3.0.9)
# Make sure we're in the VPN
if [[ $1 == "ppp0" ]] ; then
echo Proceeding >> $log
# Add the routes
for k in ${VPN_ROUTE_FOR_HOSTS[@]} ; do
echo Working on $k >> $log
for l in $(dig +short $k) ; do
echo Adding $l >> $log
/sbin/route add -host $l -interface $1
done
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment