OpenWrt Forum Archive

Topic: Handling WAN not available at boot.

The content of this topic has been archived on 2 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I'm using Backfire 10.03.1-rc5 on a Netgear WNDR3700 v1, connected on the WAN side to a SMC cable modem. The cable modem and the Netgear both have static routable IPs on the public interfaces (so to be clear, the Netgear is not configured to run a DHCP client on the WAN interface).

The thing is, the Netgear appears to boot faster than the modem, so when power is restored to both simultaneously, the Netgear boots first and apparently doesn't bring up the WAN interface because the link is not active. I haven't spent a great deal of time looking into what exactly is going on, but the WAN interface never becomes active in the dmesg output, and sure enough, if I log in from the LAN, the WAN interface is UP but not RUNNING.

So it seems reasonable enough to have a boot script that sleeps for a couple of minutes and then restarts WAN connectivity. But I find myself stumped on the simplest part--how to restart WAN connectivity without just rebooting (and a post-boot script that sleeps for a bit and then reboots if the Internet is not accessible is a bad recipe for a reboot loop, so I'd rather avoid that path).

ifdown && ifup eth1 results in:

interface not found.
interface not found.
/sbin/uci: Invalid argument
/sbin/uci: Invalid argument
Interface type  not supported.

To be honest, I hate shell scripting, so I have not dug into the cause of this.

Bringing down the interface and back up via ifconfig down/up does not fix the issue.

/etc/init.d/networking restart outputs "command failed: No such device (-19)" and, again, does not fix the issue.

So I could certainly dig into these errors a bit and figure out what commands are failing, but perhaps someone here can save me the trouble?

More generally, I have two questions:

1. Is there a better way to detect the WAN activation than sleeping after boot or polling in a cron job?
2. What's the best way to react to WAN activation short of a reboot?

Thanks!

Edit: FYI, at the moment I'm doing the horrible hackish reboot-if-the-network-is-down script I described. It's a workable solution, to be sure, but really even sadder than duct tape.

(Last edited by Dan0 on 28 Aug 2011, 07:05)

Same problem here!
I have the same setup (cable-modem, WNDR3700 (WNDR3700v2)) and after reboot the WAN interface doesn't come up.

relevant console output:

ADDRCONF(NETDEV_UP): eth1: link is not ready
ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready

"ifup wan" doesn't bring it up. The same two lines on the console and

root@mag81gw1 /root# ifup wan
root@mag81gw1 /root# udhcpc (v1.18.5) started
Sending discover...
Sending discover...
Sending discover...

"/etc/init.d/network restart" brings it up.

root@mag81gw1 /root# /etc/init.d/network start
Received SIGTERM
Entering released state
[Aug 28 14:37:53] radvd: ioctl(SIOCGIFMTU) failed for br-lan: No such device
[Aug 28 14:37:53] radvd: no linklocal address configured for br-lan
Cannot find device "br-lan"
connect: Network is unreachable
1.openwrt.pool.ntp.org: Unknown host
2.openwrt.pool.ntp.org: Unknown host
3.openwrt.pool.ntp.org: Unknown host
killall: ntpclient: no process killed
udhcpc (v1.18.5) started
Sending discover...
Sending select for 213.188.XXX.XXX...
Lease of 213.188.XXX.XXX obtained, lease time 86400
udhcpc: ifconfig eth1 213.188.XXX.XXX netmask 255.255.252.0 broadcast 213.188.XXX.XXX
udhcpc: setting default routers: 213.188.236.1
udhcpc: setting dns servers: 157.161.9.6 157.161.9.7
udhcpc: setting dns domain: teleport.ch
Configuration file: /var/run/hostapd-phy0.conf
Using interface wlan0 with hwaddr e0:91:f5:cc:89:a2 and ssid 'mag81gw1'
random: Only 10/20 bytes of strong random data available from /dev/random
random: Not enough entropy pool available for secure operations
WPA: Not enough entropy in random pool for secure operations - update keys later when the first station connects
Configuration file: /var/run/hostapd-phy1.conf
Using interface wlan1 with hwaddr e0:91:f5:cc:89:a4 and ssid 'mag81gw1'
random: Cannot read from /dev/random: Resource temporarily unavailable
random: Only 0/20 bytes of strong random data available from /dev/random
random: Not enough entropy pool available for secure operations
WPA: Not enough entropy in random pool for secure operations - update keys later when the first station connects
root@mag81gw1 /root#

i know i had this already once a year ago, but i don't remember how i solved it :-/
But i had also another error message in the console..

fyi,

I assume all fixes in rc4 are rolled up into rc5, no?

It's possible that adding a switch solves this problem by causing the Netgear to perceive the Ethernet connection to be active (since the link would terminate in an already-on powered hub rather than the still-booting cable modem), so this sounds like it may be the same problem. I will ask "bro" if he can confirm that a single reboot of the Netgear does not cause this problem.

I unfortunately don't know more about what must happen for an interface to be considered "running" once it's up. I'll go poke around the Internets or kernel.org (ugh).

Thanks.

Oh, and mag81, init.d/network restart does not bring it up for me, but if it does for you, you could just configure the following script to run at startup:

#!/bin/sh

COUNT=4
TARGET=8.8.8.8

count1=$(ping -c $COUNT $TARGET | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')

if [ $count1 -eq 0 ]; then
        /etc/init.d/network restart
fi

The discussion might have continued from here.