From: Stefan Huber Date: Mon, 29 Oct 2012 17:08:58 +0000 (+0100) Subject: add openvpn scripts X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=d8cf81cacda2850ac4423926888167a465579c60;p=shutils.git add openvpn scripts --- diff --git a/openvpn/setroute b/openvpn/setroute new file mode 100755 index 0000000..26081b8 --- /dev/null +++ b/openvpn/setroute @@ -0,0 +1,34 @@ +#!/bin/bash + +vpnserver="sthu.org" + +serverip=$(host ${vpnserver} | awk '{ print $4 }') +vpnip=$(route -n | grep -m 1 "tun0" | awk '{ print $1 }') + + +defgw=$(route -n | grep -m 1 "^0.0.0.0" | awk '{ print $2 }') +defif=$(route -n | grep -m 1 "^0.0.0.0" | awk '{ print $8 }') +echo "current default gw ${defgw} dev ${defif}" +echo "" + + +echo "add route to ${serverip} via dev ${defif}" +route add -host $serverip gw ${defgw} dev ${defif} +echo "remove old default route via gw ${defgw}" +route del default gw ${defgw} +echo "add default gw ${vpnip} (vpnip)" +route add default gw ${vpnip} + +echo "" +echo "Press to restore default route" +read + + +echo "restore default gw ${defgw} dev ${defif}" +route add default gw ${defgw} dev ${defif} +echo "remove default route" +route del default gw ${vpnip} +echo "remove route to ${serverip}" +route del ${serverip} gw ${defgw} + + diff --git a/openvpn/start b/openvpn/start new file mode 100755 index 0000000..9f2975b --- /dev/null +++ b/openvpn/start @@ -0,0 +1,2 @@ +#!/bin/sh +openvpn --config /etc/openvpn/sthu.org/tun0.conf verb 6