[X-Unix] How to determine which network component is failing

Stroller macmonster at myrealbox.com
Mon Jul 24 06:57:04 PDT 2006


On 23 Jul 2006, at 15:44, Charles Howse wrote:
> ...
> I have been working with curl to get the ip address, but it returns  
> a real mess:
> [charles at larry:~]$ curl -s http://192.168.254.254/Status_Router.htm
> <HTML><HEAD><TITLE>Setup</TITLE><META http-equiv=Content-Language  
> content=en-us><META http-equiv=Content-Type content='text/html;  
> charset=iso-8859-1'><style fprolloverstyle>A:hover {color: #00FFFF} 
> BODY{FONT: 10pt Arial,Helvetica,sans-serif; COLOR: black}TH {FONT:  
> bold 10pt Arial,Helvetica,sans-serif; COLOR: white;}TABLE {FONT:  
> 10pt Arial,Helvetica,sans-serif; COLOR: black; BORDER: Medium White  
> None; border-collapse: collapse}TD{font-size: 8pt; font-family:  
> Arial, Helvetica, sans-serif}.num{FONT: 8pt Courier,serif;}.bar 
> {background-color:white;}A{text-decoration: none;}A:link{color:  
> #ffffff;}A:visited{color: #ffffff;}A:hover {color: #00FFFF;}.small  
> A:link{color: #B5B5E6;}.small A:visited{color: #B5B5E6;}.small  
> A:hover {color: #00FFFF;}</style><SCRIPT  
> language=JavaScript>function pppoeAction(F,I){   F.pppoeAct.value =  
> I;   F.submit();}function DHCPAct(F,I){      F.dhcpAction.value =  
> I; F.submit();}function showAlert(){alert('');}</SCRIPT>...
> [snip a ton of html garbage]

Ummm... it would be. You need to grep it.

For my router:
   $ curl -u admin:password http://pornpipe/doc/online.sht 2> /dev/ 
null | grep -o '[[:digit:]]\{1,3\}[\.][[:digit:]]\{1,3\}[\.] 
[[:digit:]]\{1,3\}[\.][[:digit:]]\{1,3\}'
   192.168.1.43
   212.104.130.9
   192.168.1.1
   82.153.1.4
   213.152.39.89

On my system the status page <http://pornpipe/doc/online.sht> shows  
192.168.1.43 as the primary DNS server for the LAN, secondary DNS  
212.104.130.9 (my ISP's DNS server?), 192.168.1.1 is "LAN Status, IP  
address", 82.153.1.4 is the WAN gateway IP and finally 213.152.39.89  
is the router's globally-addressable IP.

Note that my grepping is probably a little clumsy, as I've never used  
"repetition operators" before. I wanted to grep for "three times  
[[:digit:]]\{1,3\}[\.] and then [[:digit:]]\{1,3\} again" but  
couldn't work out how to express that in a way that applied the  
"three times" to the "[[:digit:]]\{1,3\}[\.]"; hence I just copied &  
pasted the statement three times.

Experiment with this line & you'll understand it better - remove the  
"2> /dev/null" and you'll see that `curl` displays its status to  
stderr. The "-o" tells grep to display only the parts it finds that  
actually match the expression; I use this a LOT in my shell scripts.

I might extract only the IP I'm interested in by heading & tailing  
the output (for some reason that sounds so much nicer to me than "by  
use of `head` and `tail`") but there are probably more elegant ways  
of doing it - what happens if you're offline and the router's webpage  
only shows the first 3 of those IPs? A good Bash script will probably  
contain an "if $variable is NULL then" statement - I can't remember  
off the top of my head how to do that but I know it's described in  
the Advanced Bash Scripting Guide which is a free download and always  
close at hand when I'm writing Bash scripts here.

> I use static addresses on all the lan computers.  The dhcp server  
> on the router is turned off.
> One issue might be that the modem's lan address is 192.168.100.1,  
> and the default address for the router is 192.168.1.1.  I have  
> changed that to 192.168.254.254, and set the computers to  
> 192.168.254.*/255.255.255.0.
> Do you think it would help anything to set the router to  
> 192.168.100.254, and the computers to 192.168.100.*/255.255.255.0?
> Then everything would be on the same subnet.

Ummm... *rubs eyes*
It's kinda early in the morning here, so please excuse me if I'm  
reading that incorrectly... but the point of a router is that it  
routes between two different subnets. Ummmm... if the modem has a  
192.168.x.y IP address then that suggests it's already doing some  
NATting (certainly if the modem's external address is different). If  
you put both interfaces of the router in the same subnet I don't  
think it would work any more.

I haven't seen the source from the webpage that you use to reboot the  
router, yet. Perhaps you could repost it, please? Since that'll be  
plain-text html then an attachment would probably be quite acceptable  
to the list. Use your web-browser to navigate to that page and use  
"View > Source", but make sure you're not viewing just the source to  
a frameset. The "--form" parameter to `curl` may allow for button  
presses on a webpage.

Stroller.




More information about the X-Unix mailing list