Created
December 24, 2014 07:30
-
-
Save ajbogh/9a15138abcde619950a1 to your computer and use it in GitHub Desktop.
FixVPN routes all traffic through a local interface, except for VPN's IPs, allowing internet access.
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
#!/bin/bash | |
# Notes: use the route command to determine your device name and make changes below. | |
# Run this script only after you connect to the VPN. | |
##### EDIT BELOW ##### | |
NETWORK_DEVICE='wlan0' | |
##### END EDITABLE SECTION ##### | |
if ! hash gksu 2>/dev/null; then | |
#install gksu | |
zenity --warning --title="Missing dependency" --text="Please install gksu by typing 'sudo apt-get install gksu' from a terminal or search for gksu in the Ubuntu Software Center." | |
exit 0 | |
fi | |
# Elevate privileges to run the route commands | |
[ "$UID" -eq 0 ] || exec gksu bash "$0" "$@" | |
PERSONAL_GATEWAY=`ip route | grep "via" -m 1 | cut -d" " -f 3` | |
# Remove default route because it doesn't allow internet access | |
route del default vpn0 | |
# Add a new default route that does allow internet access | |
route add default gw $PERSONAL_GATEWAY $NETWORK_DEVICE | |
# NOTE: Any search or browser request will use the default route | |
# This ensures searches won't hit the VPN and other websites | |
# won't be blocked by the corporate security policy. | |
# Please use caution when browsing the internet or downloading files. | |
# route all traffic in the 10.x.x.x IP block to the VPN. | |
route add -net 10.0.0.0 netmask 255.0.0.0 dev vpn0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment