Created
January 17, 2015 15:16
-
-
Save andreineculau/6c2e54941a60f071225b to your computer and use it in GitHub Desktop.
route off vpn
This file contains 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
#!/usr/bin/env bash | |
exit 0 | |
# refs | |
# http://archives.aidanfindlater.com/blog/2010/02/03/use-vpn-for-specific-sites-on-mac-os-x/ | |
# http://superuser.com/questions/424862/how-do-i-make-certain-web-addresses-use-a-specific-network-adapter-on-mac-os-x | |
# http://superuser.com/questions/4904/how-to-selectively-route-network-traffic-through-vpn-on-mac-os-x-leopard | |
# Script which handles the routing issues as necessary for pppd, | |
# including for PPTP tunnels. Save this script as /etc/ppp/ip-up | |
# and make sure it is executable. | |
# | |
# When the ppp link comes up, this script is called with the following | |
# parameters | |
ifname=$1 # the interface name used by pppd (e.g. ppp3) | |
ttyname=$2 # the tty device name | |
speed=$3 # the tty device speed | |
localip=$4 # the local IP address for the interface | |
remoteip=$5 # the remote IP address | |
ipparam=$6 # the current IP address before connecting to the VPN | |
domains_file=~/foo.txt | |
dns="8.8.8.8" | |
domains_static="www.foo.com" | |
domains_dynamic="$(grep -o -e '[^/]\+.com' ${domains_file}) | sort | uniq" | |
domains="$(ls /etc/resolver) ${domains_static} ${domains_dynamic}" | |
echo "#!/usr/bin/env bash" > /etc/ppp/ip-down | |
for domain in ${domains}; do | |
hosts=$(dig +short ${domain} @${dns}) | |
for host in ${hosts}; do | |
/sbin/route add -host ${host} -interface en1 | |
echo "/sbin/route delete -host ${host} -interface en1" >> /etc/ppp/ip-down | |
done | |
done | |
echo "echo \"#!/usr/bin/env bash\" > /etc/ppp/ip-down" >> /etc/ppp/ip-down |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment