]>
git.sthu.org Git - shutils.git/blob - openvpn/setroute
5 serverip
=$
(host ${vpnserver} |
awk '{ print $4 }')
6 vpnip
=$
(route
-n |
grep -m 1 "tun0" |
awk '{ print $1 }')
9 defgw
=$
(route
-n |
grep -m 1 "^0.0.0.0" |
awk '{ print $2 }')
10 defif
=$
(route
-n |
grep -m 1 "^0.0.0.0" |
awk '{ print $8 }')
11 echo "current default gw ${defgw} dev ${defif}"
15 echo "add route to ${serverip} via dev ${defif}"
16 route add
-host $serverip gw
${defgw} dev
${defif}
17 echo "remove old default route via gw ${defgw}"
18 route del default gw
${defgw}
19 echo "add default gw ${vpnip} (vpnip)"
20 route add default gw
${vpnip}
23 echo "Press to restore default route"
27 echo "restore default gw ${defgw} dev ${defif}"
28 route add default gw
${defgw} dev
${defif}
29 echo "remove default route"
30 route del default gw
${vpnip}
31 echo "remove route to ${serverip}"
32 route del
${serverip} gw
${defgw}