Last active
April 3, 2017 18:17
-
-
Save dw72/7de9c29c9ce3d90462daa43de75450e5 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
#!/bin/bash | |
config=/etc/vpnc/zsp2.conf | |
start() { | |
echo "Connecting to vpn..." | |
vpnc $config | |
echo "Setting up routing table..." | |
ip r del default dev tun0 | |
ip r add 192.168.1.0/24 dev tun0 | |
ip r add 192.168.11.0/24 dev tun0 | |
ip r add 192.168.12.0/24 dev tun0 | |
ip r add 192.168.23.0/24 dev tun0 | |
ip r add 192.168.26.0/24 dev tun0 | |
} | |
stop() { | |
echo "Cleaning routing table..." | |
ip r del 192.168.1.0/24 dev tun0 | |
ip r del 192.168.11.0/24 dev tun0 | |
ip r del 192.168.12.0/24 dev tun0 | |
ip r del 192.168.23.0/24 dev tun0 | |
ip r del 192.168.26.0/24 dev tun0 | |
echo "Disconnecting from vpn..." | |
vpnc-disconnect | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart}" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment