Skip to content

Instantly share code, notes, and snippets.

@dw72
Last active April 3, 2017 18:17
Show Gist options
  • Save dw72/7de9c29c9ce3d90462daa43de75450e5 to your computer and use it in GitHub Desktop.
Save dw72/7de9c29c9ce3d90462daa43de75450e5 to your computer and use it in GitHub Desktop.
#!/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