Last active
December 5, 2017 14:12
-
-
Save bruce-shi/c6a2a6a936a695e37c0fc0f452b6a8db to your computer and use it in GitHub Desktop.
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 | |
if (( EUID != 0 )); then | |
echo “Please run this command with sudo” 1>&2 | |
exit 1 | |
fi | |
WIRELESS_INTERFACE=en0 | |
VPN_INTERFACE=ipsec0 | |
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 $VPN_INTERFACE | |
route -n add -net default $GATEWAY | |
for subnet in 192.168.10 192.168.20 192.168.100 | |
do | |
route -n add -net $subnet -interface $VPN_INTERFACE | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment