On 6/10/02 1:35 PM, "bob ackerman" <[EMAIL PROTECTED]> wrote:

> my box is behind a D-Link router 704.
> The router gets its ip from my isp using dhcp.
> anyone know how to get that external ip from the router?
> is any module designed to find your external ip when  you are on a lan?
> router is admined from a web page, so i guess it is possible to using LWP
> (or some other module?) to retrieve the info from the web page.

LWP's a good thought.  A fellow named Jerry LeVan posted a script he used to
get the IP address from a Linksys router; I modified it somewhat to get the
IP address from my Macsense router.  You can probably easily adapt it to
your own needs.  Here's the relevant portion of the script:

#!/usr/bin/perl -w

use strict;
use LWP::UserAgent;

my $pattern = '<b>Public IP Address</td><td bgcolor=c3c3c3><font
face=verdana size=-1><b>(\d+\.\d+\.\d+\.\d+)</td>';

# Fetch the page

my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => 'http://192.168.1.1/Status.htm');
$req->authorization_basic('admin', 'admin');
my $thePage = $ua->send_request($req);

if ($thePage->content =~ m|$pattern|os)
 {   ## Do whatever you want with $1
}
else {
  ## Whoops!
} 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to