What's new

N66U losing WAN after modem reboot

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

I have this in my /jffs/scripts/wan-start script

Code:
#!/bin/sh
logger "WAN Up: New IP address is $(nvram get wan_ipaddr)"

sleep 20
killall wan_check.sh
/mnt/usb4gb/wan_check.sh &

and the contents of my usb mounted wan_check.sh script

Code:
#!/bin/sh
#space separated list of hosts to check
HSTS="$(nvram get wan_gateway) $(nvram get wan_dns) 8.8.8.8 8.8.4.4"
# No of times to check each host before trying next
TRIES=3
# How often to check in seconds if OK
TCHECK=30
# How long to wait if all hosts fail
TFAIL=10
# How many fails before restarting with dhcpc_renew
NFAIL=3

chk=0

LG(){
    echo "wan_check: $@"|/usr/bin/logger -s
}

CHK(){
    cnt=0
    chk=0
    while [ $cnt -lt $TRIES ]; do
        if /bin/ping -c 1 $@ >/tmp/wan_check.log; then
            chk=1
            break
        else
            sleep 1
            let cnt=cnt+1
        fi
    done
}

dn=0
LG monitoring WAN connection using ping
while [ $dn -lt $NFAIL ]; do
    for h in $HSTS; do
        UP=0;
        CHK $h
        if [ $chk -gt 0 ]; then
            UP=1
            break
        else
            LG ping check failed $h
        fi
    done

    if [ $UP -gt 0 ]; then
        dn=0
        sleep $TCHECK
    else
        let dn=dn+1
        sleep $TFAIL
    fi
done

LG "renewing dhcp wan"
killall -USR1 udhcpc
sleep 30
service restart_wan

It's a modded version of something I found on the net. It is slow to detect a fault because my ISP seems to drop ping packets when line is very busy, and I don't want false restarts of the wan. There's another variant around that reboots the router if the restart_wan doesn't work. The first 2 ips to ping are not correct nvram vars if you try dual wan.

hey, I was checking this and reading a bit around, and I have some question:
- isn't it more graceful to use dhcpc-event and check for deconfig to trigger the script leaving wan alone?
- rather than being always on, would it be better or worse to use a cron job and exit if connectivity is on? In this case the first script would move a file to the cron folder instead of calling directly the checker.


btw I checked the wanduck code and I gave up. If there is a fix to be written, I'll let expert hands deal with it :)
 
I don't see much difference between dhcp-event and wan-up script, have just used the latter since it is standard in Tomato. Not sure about deconfig - in my case the issue is that the router sometimes doesn't deconfig when it should renew automatically.
I'm sure you can use crond for once per minute, might be less messy than the 'sleep' tasks that you see in ps listing when my script running, and avoid the multiple instantiation potential. See the 'cru' script command for easy setup of cron jobs.

Other users of this script and a simple alternative at the end here, not sure your problem is the the same though
http://www.snbforums.com/threads/wan-ip-renew-issue.26995/

ISTR that an unnecessary forced dhcp renew is messy, so don't want to do it unnecessarily - maybe BusyBox udhcpc could now do this more quietly, in similar way that Windows/Games Consoles do whenever they notice an issue in contacting the internet?

I always have similar thoughts about wanduck - I'm sure someone could get rid of the "ISP's DHCP did not function properly" message too!
 
Recovering from a modem reboot is actually quite difficult due to all the state changes the modem goes thru and the fact that a lot of the router recovery is event driven. I did quite a bit of work on my fork to try and improve things, and have tested it quite a bit on the AC68 (along with simulated power fails where I drop and restore the power to both the modem and router). I'd be interested in any feedback if you decide to try it on the N66.

But, I'd be more concerned about what is causing the reboot to begin with when you answer a call. Best case the recovery will take a couple of minutes, and I think that would be pretty disruptive.
 
Recovering from a modem reboot is actually quite difficult due to all the state changes the modem goes thru and the fact that a lot of the router recovery is event driven. I did quite a bit of work on my fork to try and improve things, and have tested it quite a bit on the AC68 (along with simulated power fails where I drop and restore the power to both the modem and router). I'd be interested in any feedback if you decide to try it on the N66.

But, I'd be more concerned about what is causing the reboot to begin with when you answer a call. Best case the recovery will take a couple of minutes, and I think that would be pretty disruptive.
I'll probably try your fork, I dragged this further for a combination of laziness and little time :)

And I am worried about the reboots, I contacted the ISP, they cannot see the problem, it used to happen 100% of the times, but now unfortunately it's more random.
I think it's the sip implementation of the modem FW, but without them looking at some log to pinpoint where it crashes, they won't commit to any solution.
 
Recovering from a modem reboot is actually quite difficult due to all the state changes the modem goes thru and the fact that a lot of the router recovery is event driven. I did quite a bit of work on my fork to try and improve things, and have tested it quite a bit on the AC68 (along with simulated power fails where I drop and restore the power to both the modem and router). I'd be interested in any feedback if you decide to try it on the N66.

But, I'd be more concerned about what is causing the reboot to begin with when you answer a call. Best case the recovery will take a couple of minutes, and I think that would be pretty disruptive.

hi john,
good news, i finally tried your fork and in the few experiments I did with modem reboot, the router got internet back all the times :)

bad news (only for me), my provider still cannot understand my modem reboot problem, they cannot accept that a customer has any idea of what's going on and look in the direction he is pointing at...
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top