Reboot on PPPOE Failure and Script Problem

Hello my friends. I have a problem with my PPPOE, everytime I start to download huge files, the PPPOE connection breaks after about 10 minutes, after that, The modem cannot reach the DSL network until I reboot the whole device manually.

Device: TP-Link TD-W8970 V1
OpenWrt: 18.06.1

I found this on mullvad website to automatically reboot my device, but it need some changes:

#https://mullvad.net/en/help/running-wireguard-router/

#!/bin/sh
# ping mullvad dns that can only be reached via the VPN tunnel
# if no contact, reboot!

tries=0
while [[ $tries -lt 5 ]]
do
        if /bin/ping -c 1 10.64.0.1
        then
                echo "wg works"
                exit 0
        fi
        echo "wg fail"
        tries=$((tries+1))
done
echo "wg faild 5 times - rebooting"
reboot

I made some changes to it:

#!/bin/sh
# ping my dsl wan address that can only be reached when connection established
# if no contact, reboot!

tries=0
local_wan=ifstatus wan |  jsonfilter -e '@["ipv4-address"][0].address'
while [[ $tries -lt 5 ]]
do
        if /bin/ping -c 1 $local_wan
        then
                echo "wg works"
                exit 0
        fi
        echo "wg fail"
        tries=$((tries+1))
done
echo "wg faild 5 times - rebooting"
reboot

I have some problems in line 6 (It's unable to save the result in the variable)
and line 9 (It's unable to ping a value from the variable)
(I need to get my current assigned wan ip address and ping this address, that's way I use the ifstatus wan | jsonfilter -e '@["ipv4-address"][0].address')

First the version you are running is outdated and unsupported. There is 18.06.8 from the same branch or 19.07.2 from the latest.
Second there is watchcat package for the same job.
But you should first make sure that the issue isn't cause by bad MTU or cannot be fixed with LCP keepalives.

2 Likes