Created
January 31, 2017 19:27
-
-
Save dkoloditch/e5558e156180eaa8bc5aeb1bd7552a13 to your computer and use it in GitHub Desktop.
OS X Cisco IPSEC VPN Post-Connection Split-Tunneling Script
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 | |
# per http://www.shadabahmed.com/blog/2013/08/11/split-tunneling-vpn-routing-table/ | |
if (( EUID != 0 )); then | |
echo "Please, run this command with sudo" 1>&2 | |
exit 1 | |
fi | |
WIRELESS_INTERFACE=en0 | |
TUNNEL_INTERFACE=utun0 | |
GATEWAY=$(netstat -nrf inet | grep default | grep $WIRELESS_INTERFACE | awk '{print $2}') | |
echo "Resetting routes with gateway => $GATEWAY" | |
echo | |
route -n delete default -ifscope $WIRELESS_INTERFACE | |
route -n delete -net default -interface $TUNNEL_INTERFACE | |
route -n add -net default $GATEWAY | |
# custom route add for server behind VPN | |
# route -nv add -net SERVERIPHERE -interface utun0 | |
for subnet in 10.105 | |
do | |
route -n add -net $subnet -interface $TUNNEL_INTERFACE | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment