Hi,
I thought to share this useful script with the community and see if there are some useful improvements to be made.
This script checks your enabled VPN connections and will restart in case of an issue like interface down or unable to ping the external source. You add this script to cron and run it e.g. every 5 minutes. It'll add log entries in the system log.
Enjoy!
I thought to share this useful script with the community and see if there are some useful improvements to be made.
This script checks your enabled VPN connections and will restart in case of an issue like interface down or unable to ping the external source. You add this script to cron and run it e.g. every 5 minutes. It'll add log entries in the system log.
Bash:
#!/bin/sh
for i in 1 2 3 4 5
do
if [ `nvram get vpn_client"$i"_state` -gt 0 ]
then
logger -s -p user.notice "VPN $i Enabled"
if [ `ip route add to 103.224.182.212 dev tun1"$i" | grep "Network is down" | wc -l` -eq 0 ]
then
if [ `ping -c 1 103.224.182.212 | grep "100% packet loss" | wc -l` -eq 1 ]
then
logger -s -p user.notice "VPN $i down, restarting..."
service restart_vpnclient"$i"
else
logger -s -p user.notice "VPN $i up, no action required..."
fi
else
logger -s -p user.notice "VPN $i down, restarting..."
service restart_vpnclient"$i"
fi
ip route delete to 103.224.182.212 dev tun1"$i"
fi
done
Enjoy!