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

Help with Cron job to reboot Router if VPN fails

Discussion in 'Tomato Firmware' started by Hardrock, Feb 25, 2014.

  1. Hardrock

    Hardrock Reformed Router Member

    Hi all,

    Can't seem to get a script to work to reboot my E4200 router running Shibby Tomato if the VPN fails in client mode

    My VPN provider supplies a VPN script with Firewall parameters as follows

    iptables -t nat -I POSTROUTING -o tun0 -j MASQUERADE
    iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

    At some point everyday, the VPN will drop at some point and internet access is lost. The only way to fix it is by rebooting the router.

    I'd like a simple cron job script that continuously monitors the VPN and will reboot the router automatically if say it can't ping an internet address. Could someone in the know please advise on this?

    If what I want to achieve can be done without rebooting then even better! I just wanted to keep it simple that's all.
  2. mmosoll

    mmosoll Serious Server Member

    In another discussion of this forum I found this script. I use it to check if WDS is active in my network between two routers. I included it in Administration/Script/Init of both router (checking time is 8 minutes). Maybe this sample can help you:

    Note: is the IP of second router, only this parameter change in both scripts

    sleep 5
    cat <<END > /tmp/keepalive
    ping -c5 >/dev/null || reboot
    chmod 755 /tmp/keepalive
    cru a keepalive "*/8 * * * * /tmp/keepalive >/dev/null 2>&1"

Share This Page