What's new

script to restart VPN client if connection goes down?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

DTS

Regular Contributor
Sometimes, after a few days, I may need to restart my VPN (client) connection. Is there any script for Asus wireless routers which will do this automatically?

Restarting the router daily doesn't help. For example, I might restart it at 5:00 am, but if the VPN connection goes down at, say, 4pm, I don't want it to stay down until the next 5:00am (or whenever I manually restart it).

I do already have this config line:
Code:
pull-filter ignore auth-token
And my connection is generally pretty good, often not giving me any trouble at all until my ISP has a temporary glitch (which can happen as often as every few days). When that happens, I need to reconnect my VPN client and I'm looking for an automated way to do it.
 
Sometimes, after a few days, I may need to restart my VPN (client) connection. Is there any script for Asus wireless routers which will do this automatically?

Restarting the router daily doesn't help. For example, I might restart it at 5:00 am, but if the VPN connection goes down at, say, 4pm, I don't want it to stay down until the next 5:00am (or whenever I manually restart it).

I do already have this config line:
Code:
pull-filter ignore auth-token
And my connection is generally pretty good, often not giving me any trouble at all until my ISP has a temporary glitch (which can happen as often as every few days). When that happens, I need to reconnect my VPN client and I'm looking for an automated way to do it.

RMerlin firmware contains a crude VPN watchdog script for each ACTIVE VPN connection:
Code:
cru l | grep watchdog

*/2 * * * * /etc/openvpn/server1/vpns-watchdog1.sh #CheckVPNServer1#
*/2 * * * * /etc/openvpn/server2/vpns-watchdog2.sh #CheckVPNServer2#
*/2 * * * * /etc/openvpn/client1/vpnc-watchdog1.sh #CheckVPNClient1#
*/2 * * * * /etc/openvpn/client2/vpnc-watchdog2.sh #CheckVPNClient2#
*/2 * * * * /etc/openvpn/client3/vpnc-watchdog3.sh #CheckVPNClient3#
e.g. for VPN Client 1
Code:
cat /etc/openvpn/client1/vpnc-watchdog1.sh

#!/bin/sh

if [ -z $(pidof vpnclient1) ]
then
   service restart_vpnclient1
So you could improve the VPN watchdog script by including (or create a separate cru aka cron schedule) a call to execute a more comprehensive/useful script such as ChkVPNIP.sh to restart the VPN client (rather than send an e-mail).
 

Similar threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top