What's new

WAN IP renew issue

  • 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!

Espens

New Around Here
I've had a RT-AC66U for over a year and it has been working flawlessly even on stock firmware.

I recently moved to a new house; and had to move from fiber to cable. So a new ISP and new HW, and the setup has been unstable to say the least. The problem is that the router looses internet connection.

After I started having issues I upgraded to Merlin, but the situation is just the same.

I purchased an Arris 6184 modem and I'm connected to Time Warner in SoCal.

The issue seems to be related to udhcp and the renewal of the dhcp address.

Issue happens frequently when the dhcp lease expires or the modem reboots (Cable Modem Reboot due to T4 timeout).

The router logs
WAN(0) Connection: ISP's DHCP did not function properly.
stop_nat_rules: apply the redirect_rules!

The following will resolve the issue
* Router reboot
* Remove and reinsert the WAN cable in the router.
* Restart udhcpc manually
* Toggle Internet Connection in the web UI

Without the above it seems like udhcpc has given up and never retries to renew.

It seems as if the modem has a built in dhcp server, although on initial boot it gets its IP from the TWC server my thought is that on disconnect / reboot the router gets confused by a reply from the modem instead. I called TWC who sent some config changes to my modem. Not sure what they did, but modem still says dhcp enabled. Situation got slightly better but it's still not at an acceptable level.

Is it possible to turn on verbose logging in udhcpc? I can't find much info from udhcpc in the syslog

Any scripts I could run? I'm considering adding a dhcpc-event script on deconfig checking if wan_gateway is not set (will need to verify that it's actually not set) and then send SIGUSR1 and SIGUSR2 to dhcpc. Problem is that it might end up in a endless loop if it's not possible to renew, and besides I'm not even sure if deconfig will be called in this situation.

Any suggestions or experiences with similar situations?
 
I have a similar problem in the UK, the renew at half the wan dhcp lease doesn't always work, and eventually the lease expires. There is a message in the logs about ISP dhcp server not responding correctly at router start - but its not specific to asuswrt, get the same with Tomato.

I use the following script, saved on my usb stick as wan_check.sh

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 10
service restart_wan

It is deliberately slow to detect real failures, because I know my isp drops pings when overloaded, so I try to avoid false failure detection.

The above started from /jffs/scripts/wan-start

Code:
#!/bin/sh
logger "WAN Up: New IP address is $(nvram get wan_ipaddr)"
killall wan_check.sh
/mnt/usb4gb/wan_check.sh &

Note I expect the USR1 to udhcpc to work and kill/restart the monitoring script before the last try to restart the wan.

Saves me from remote telephone support to home calls!
 
Thank you for the script. I added it to my router and we'll see if it helps. It probably will as our issues seems to very similar.

The issue is probably present on several of the firmware using udhcpc which seems to be common in busybox. I'm surprised that this isn't reported more often.
 
Curiously my script was needed this morning, clearly ISP reconfigured something and I now have a new WAN IP, with the number of checks and timeouts currently configured this is how long it took to restore my connection, but was successful!

Code:
Sep 11 05:57:32 admin: wan_check: ping check failed
...
Sep 11 06:01:44 admin: wan_check: ping check failed 8.8.8.8
Sep 11 06:02:17 admin: wan_check: ping check failed 8.8.4.4
Sep 11 06:02:27 admin: wan_check: renewing dhcp wan
...
Sep 11 06:03:52 WAN Connection: WAN was restored.
 
Some people who are sporadically facing issues with their AC87 suspect that those are connected to IP related problems with their respective ISPs.

I'm one of them and so I'm wondering if that same script could be used with the AC87 as well. Or would it need any adjustments?

What also interests me: for how long does the script actually run on average?
 
It should work on the AC87 too.

The script starts with wan-up and runs in the background and pings the servers. When ping has failed a number of times it will try to have udhpc renew and then restart the wan and exit. On restart of the wan the script will get started again. So it would be running forever.
 
The script works very well here. Kicks in at least one time pr. day.

Sep 12 14:25:38 WAN(0) Connection: ISP's DHCP did not function properly.
Sep 12 14:25:38 stop_nat_rules: apply the redirect_rules!
Sep 12 14:26:15 admin: wan_check: ping check failed
....................
Sep 12 14:34:19 admin: wan_check: ping check failed
Sep 12 14:34:29 admin: wan_check: renewing dhcp wan
Sep 12 14:34:30 custom script: Running /jffs/scripts/dhcpc-event (args: renew)
Sep 12 14:34:30 CHECKWAN: logger dhcpc event renew
Sep 12 14:34:39 rc_service: service 32549:notify_rc restart_wan
 
Some people who are sporadically facing issues with their AC87 suspect that those are connected to IP related problems with their respective ISPs.

I'm one of them and so I'm wondering if that same script could be used with the AC87 as well. Or would it need any adjustments?

What also interests me: for how long does the script actually run on average?

I've used variants of this script for years with both Tomato and asuswrt firmwares on different routers, it should run all the time after the first successful wan start, with just one successful ping to your wan gateway every 30 seconds (script variable). It is deliberately slow to detect wan failure, I had a period of intermittent internet which led to false detections - restarting the wan breaks all connections and is disruptive if not necessary!

There's another version around with an extra outer loop which would reboot the router as last resort if so a number of attempts at dhcp renew or wan-start.

I believe some versions of dd-wrt have a configurable script built-in - but to prove its not a new problem ...

http://www.dd-wrt.com/phpBB2/viewtopic.php?p=667006

Asuswrt does have a program called wanduck which should also be monitoring the wan, I recall it uses kernel stats counters, rather than an external ping, and seems that it can't differentiate between good traffic and bad. I do not know how Windows detects 'no internet', but wouldn't be surprised it does something similar, it definitely starts sending dhcp ack/renew requests which would solve a similar problem. It would be better for wanduck to be enhanced since it should work with all wan types and dual wan failovers etc and Asus have made it opensource - there's even a ping check #defined out!

https://github.com/RMerl/asuswrt-merlin/blob/master/release/src/router/rc/wanduck.c#L377
 
I've used variants of this script for years with both Tomato and asuswrt firmwares on different routers, it should run all the time after the first successful wan start, with just one successful ping to your wan gateway every 30 seconds (script variable). It is deliberately slow to detect wan failure, I had a period of intermittent internet which led to false detections - restarting the wan breaks all connections and is disruptive if not necessary!

There's another version around with an extra outer loop which would reboot the router as last resort if so a number of attempts at dhcp renew or wan-start.

I believe some versions of dd-wrt have a configurable script built-in - but to prove its not a new problem ...

http://www.dd-wrt.com/phpBB2/viewtopic.php?p=667006

Asuswrt does have a program called wanduck which should also be monitoring the wan, I recall it uses kernel stats counters, rather than an external ping, and seems that it can't differentiate between good traffic and bad. I do not know how Windows detects 'no internet', but wouldn't be surprised it does something similar, it definitely starts sending dhcp ack/renew requests which would solve a similar problem. It would be better for wanduck to be enhanced since it should work with all wan types and dual wan failovers etc and Asus have made it opensource - there's even a ping check #defined out!

https://github.com/RMerl/asuswrt-merlin/blob/master/release/src/router/rc/wanduck.c#L377
Thanks a lot! It's running on my AC87 now, I was able to verify that it successfully documents its pings in the /tmp/wan_check.log file now. I might modify it to perform a full reboot instead, but for now I'll leave it alone.

BTW: /sbin/wanduck is indeed present in the list of running processes as well.

We are not even sure if those issues that motivated me to run this script are 100% related to WAN DHCP issues, however if they are, then I guess a full reboot might be necessary (since we're talking about issues which even make it impossible to log onto the router via SSH or HTTP)
 
Rather than throw away the ping result to /dev/null the above script keeps the last ping response in the ram disk tmp folder, date/time only stored as modification time of the file. Failure of 3 attempts to ping 1 second apart messages go to syslog.
 
my script is not so long and work also good

#!/bin/sh
if ping -w 10 -c 1 212.247.8.38 > /dev/null; then
echo "SERVERNAME=on"
else
echo "SERVERNAME=off"
killall -SIGUSR2 udhcpc
fi
 

Latest threads

Sign Up For SNBForums Daily Digest

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