On Jul 24, 2006, at 12:27 PM, Wing Wong wrote: > On 7/23/06, Charles Howse <chowse at charter.net> wrote: >> Hardware setup: >> ISP: Charter Communications, 2 megabit service >> Cable Modem: Motorola SB4200 Surfboard >> Router: Linksys Etherfast(r) Cable/DSL Router BEFSR41 V3 Firmware >> Version: 1.04.17 >> Computers: 2 FreeBSD 6.1-RELEASE. 1 Mac OS X 10.4.7, 100 baseT >> ethernet connections on all >> >> This morning, I was offline, and just by accident decided to try and >> release and renew the ip address using the web interface of the >> router. >> BINGO! Online again! >> >> Is this an indication that the router is not noticing that the lease >> has expired on my dhcp assigned ip address from the modem? Or is it >> an indication that the modem is not renewing it's ip address? Or is >> it something else? >> >> Can I tell the router to release / renew the ip address from a shell >> script? > > Yes. I have a WRT54G Linksys router hooked up to my cablemodem and > this does indeed happen once in a while. Basically, when this happens, > one of two things happen: > > 1) the cablemodem/service has died and the cablemodem needs to be > power-cycled. > 2) the dhcp lease needs to be renewed. > > Typically, I've found the lease to work fine by itself. But from time > to time, it doesn't. :/ The reasons for this vary, but I'm guessing > it's someone bouncing something over at the cable provider side and > the lease is just "forgotten", leaving your router with a useless > lease. So, hitting the release/renew will let you grab a new useful > lease, and back on the net. > > I suppose you could script a lynx application to login to the web > interface of your Linksys router and perform a lease release/renew > once in while or when it is unable to access some remote server on the > internet. > > Ie, > > 1) am I able to see the world? > ** check google.com > ** check msn.com > ** check yourfavoritesite.com > If at least one is up, then you are essentially live and the other two > sites are coincidentally dead. > > 2) If I'm not up, let's run the scripted lynx session to perform a > release/renew of my IP address on the router. > > 3) Check output of the script. Did I actually get an IP address or am > I still stuck with 0.0.0.0? Wait a bit longer and run the scripted > lynx to read the DHCP address from the router again. If fail yet > again, scream for help!! > > If you have some means to, you could script a powercycle of the cable > modem itself with an intelligent power socket. (serial control or over > net control) Just make sure you don't powercycle more frequently than > necessary. I've blown devices that way. ;) If you powercycle every > 30seconds to every 5 minutes, it's amazing what 2 solid weeks of power > cycling will do to a device. > Here's what I have so far (not working to suit me), but we haven't thought out all the scenarios yet. Not ready to release/renew the dhcp lease nor reboot the modem yet. Example: I ran what I have so far with the modem in standby, and terminal returned: [charles at larry:~]$ bin/online.sh ping: cannot resolve google.com: Unknown host That makes sense, but the $logfile now contains: Tue Jul 25 18:19:30 CDT 2006 host1 online, exiting That's because the script didn't return any ping results, just the failure to resolve the name. I need help with: 1) what if my 3 pings returns only 1, or 2? That equals online, but it's easier to test against $offline (below). Therefore, the script will think the host is offline unless it returns all 3 pings. #!/bin/bash logfile=Documents/online.txt stats=`curl -s http://192.168.100.1/signaldata.html | grep dB | tr -d \<TD\> | tr -d /` offline='3 packets transmitted, 0 packets received, 100% packet loss' what_failed () { echo >> $logfile echo OFFLINE >> $logfile date >> $logfile ping -c 3 localhost | tail -3 >> $logfile echo >> $logfile ping -c 3 larry | tail -3 >> $logfile echo >> $logfile ping -c 3 moe | tail -3 >> $logfile echo >> $logfile ping -c 3 router | tail -3 >> $logfile echo >> $logfile ping -c 3 modem | tail -3 >> $logfile echo >> $logfile echo "$stats" >> $logfile } if [ ! "`ping -c 3 google.com | grep packets`" == "$offline" ] ; then date >> $logfile echo host1 online, exiting >> $logfile exit 0 elif [ ! "`ping -c 3 microsoft.com | grep packets`" == "$offline" ] ; then date >> $logfile echo host2 online, exiting >> $logfile exit 0 elif [ ! "`ping -c 3 yahoo.com | grep packets`" == "$offline" ] ; then date >> $logfile echo host3 online, exiting >> $logfile exit 0 else what_failed fi exit 0 -- Thanks, Charles http://bubbabbq.homeunix.net