Created
October 11, 2014 19:31
-
-
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
This file contains hidden or 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
#!/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