1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

script to restart VPN client if connection goes down?

Discussion in 'ASUS Wireless' started by DTS, Oct 15, 2018.

  1. DTS

    DTS Occasional Visitor

    Aug 28, 2015
    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:
    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.
  2. Martineau

    Martineau Very Senior Member

    Jul 8, 2012
    RMerlin firmware contains a crude VPN watchdog script for each ACTIVE VPN connection:
    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
    cat /etc/openvpn/client1/vpnc-watchdog1.sh
    if [ -z $(pidof vpnclient1) ]
       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).
    DTS likes this.