Skip to content

Instantly share code, notes, and snippets.

@andersonvom
Created October 11, 2014 19:31
Show Gist options
  • Save andersonvom/650cdc7c8117eedfa955 to your computer and use it in GitHub Desktop.
Save andersonvom/650cdc7c8117eedfa955 to your computer and use it in GitHub Desktop.
Routing configuration to use the VPN for VPN stuff, and default gateway for everything else
#!/bin/bash
VPN_DEVICE=utun0
VPN_NETWORK=10
DEFAULT_GATEWAY=192.168.1.1 # home
host_exceptions=(
xxx.xxx.xxx.xxx # Some public service that needs to be accessed from the VPN
)
sudo route -nv add -net $VPN_NETWORK -interface $VPN_DEVICE
for exc in ${host_exceptions[@]}
do
sudo route -nv add -host $exc -interface $VPN_DEVICE
done
sudo route change default $DEFAULT_GATEWAY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment