Skip to content

Instantly share code, notes, and snippets.

@dkoloditch
Created January 31, 2017 19:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dkoloditch/e5558e156180eaa8bc5aeb1bd7552a13 to your computer and use it in GitHub Desktop.
Save dkoloditch/e5558e156180eaa8bc5aeb1bd7552a13 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