Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save djsmiley2k/febf3d3fee7efede38f920bfbc43585b to your computer and use it in GitHub Desktop.
Save djsmiley2k/febf3d3fee7efede38f920bfbc43585b to your computer and use it in GitHub Desktop.
OS X Cisco IPSEC VPN Post-Connection Split-Tunneling Script
#! /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