Skip to content

Instantly share code, notes, and snippets.

@shrwnsan
Last active January 3, 2016 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrwnsan/8502078 to your computer and use it in GitHub Desktop.
Save shrwnsan/8502078 to your computer and use it in GitHub Desktop.
To setup a VPN for specific websites, in OS X. Based on this writeup: http://archives.aidanfindlater.com/blog/2010/02/03/use-vpn-for-specific-sites-on-mac-os-x/ Add "ip-up" file/content below to "/etc/ppp". Then "chmod a+x /etc/ppp/ip-up".
#!/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
#
## Routing setup for VPN
# Array of IP addresses of the VPN server(s)
# I have it grab the list of round-robin'ed IP addresses based on the domain name
VPN_HOSTS=$(dig +short inside.mcgill.ca)
# Array of hostns to route for
# These are the domain names and IP addresses that will be accessed through the VPN
VPN_ROUTE_FOR_HOSTS=(www.elsevier.com www.sciencedirect.com www.thelancet.com www.cmaj.ca scholar.google.com ncbi.nlm.nih.gov bmj.com)
# Make sure we're in the VPN
for i in ${VPN_HOSTS[@]} ; do if [[ $i == ${5:-} ]] ; then
# Add the routes
for k in ${VPN_ROUTE_FOR_HOSTS[@]} ; do
for l in $(dig +short $k) ; do
/sbin/route add -host $l -interface $1
done
done
fi ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment