Created
April 19, 2013 03:55
-
-
Save davidpelaez/5418040 to your computer and use it in GitHub Desktop.
Route some ips over VPN ppp0 mac os x interface via http://archives.aidanfindlater.com/blog/2010/02/03/use-vpn-for-specific-sites-on-mac-os-x/
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 | |
| # | |
| # 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