Lately, my cable connection gets disconnected too often. To automate reconnection, I installed a simple watchdog script that pings outside address and if there is no response it restarts router network. It’s not most efficient, since only WAN needs to be restarted, but it does the job.
Here is a simple watchdog script.
#!/bin/sh n=0 while [ $n -lt 10 ] do if /bin/ping -c 1 188.8.131.52 >/dev/null then exit 0 fi n=$((n+1)) done /etc/init.d/network restart
First, ssh to router and create this script
ssh firstname.lastname@example.org nano /root/watchdog.sh chmod +x /root/watchdog.sh
Save it to
/root/watchdog.sh, and give executable permissions
chmod +x /root/watchdog.sh
Add it to cron in order to execute it every minute:
* * * * * /root/watchdog.sh
You can either add this line using luci web interface at
or just edit
Make sure cron is enabled!