My Router Hangs :(
Posted: Thursday 24 January 2019 10:52
Ciao,
My DDWRT sometimes hangs without an apparent reason (probably it reaches the max connections without closing them... )
so Instead of schedule a reboot I want to manage a reboot on demand.
The router itself has a whatchdog deamon, but since it hangs... it is quite useless!
So I decide to setup a workaround to check connectivity and taka action if needed.
The requirements are:
- A ping Hardware and device (I use 8.8.8.8 to check internet connectivity)
- A plug (I use ZWave, but it could be a GPIO with a rele or whatever you want, but NOT a wifi/network device!!)
the scripts runs once a hour anche check the ping device...
if it is off for more that 5 minutes then it means internet in unreachable due to the router, so let's reboot it.
It does this for max 3 times, then, as soon as the network is back reachable, it reset the counter.
Hope you will find this interesting:
not yet tested....
I'm at work right now and my router.... well... yes... it hanged this noght!

My DDWRT sometimes hangs without an apparent reason (probably it reaches the max connections without closing them... )
so Instead of schedule a reboot I want to manage a reboot on demand.
The router itself has a whatchdog deamon, but since it hangs... it is quite useless!
So I decide to setup a workaround to check connectivity and taka action if needed.
The requirements are:
- A ping Hardware and device (I use 8.8.8.8 to check internet connectivity)
- A plug (I use ZWave, but it could be a GPIO with a rele or whatever you want, but NOT a wifi/network device!!)
the scripts runs once a hour anche check the ping device...
if it is off for more that 5 minutes then it means internet in unreachable due to the router, so let's reboot it.
It does this for max 3 times, then, as soon as the network is back reachable, it reset the counter.
Hope you will find this interesting:
Code: Select all
local maxRetry = 3 -- Max Retries before quit rebooting the router
local waitSec = 30 -- Seconds to wait before powering back up the router
local routerPingDev = 'PING_ROUTER' -- Router Ping Device (see Ping Hardware)
local routerPlugDev = 'PLUG_ROUTER' -- Router Plug Device
return {
on = {
timer = {'Every 60 minutes'}
},
data = {
actRetry = { initial = 0 }
},
execute = function(dz)
local rtrActive = dz.devices(routerPingDev)
local rtrDevice = dz.devices(routerPlugDev)
if rtrActive.state == 'Off' and rtrActive.lastUpdate.minutesAgo >= 5 then ' Reboot
dz.data.actRetry = dz.data.actRetry + 1
if dz.data.actRetry <= maxRetry then
dz.notify('Rebooting the router', 'Looks like LAN/WAN are unreachable... rebooting the router for the '..dz.data.actRetry..'time[s]')
rtrDevice.switchOff()
rtrDevice.switchOn().afterSec(waitSec)
end
elseif rtrActive.state == 'On' and dz.data.actRetry ~= 0 then
dz.data.actRetry = 0
end
end
}
I'm at work right now and my router.... well... yes... it hanged this noght!


