Re: Obtaining my IP, strange results



T wrote:
... there is no reliable way to get my IP now.

I know it's not the answer to your specific question, but in terms of getting your IP address There's More Than One Way To Do It (tm) :-)

On my LinkSys DSL router I use a Perl script which uses LWP and HTML::TreeBuilder to get the status page from the router and grok out its IP address.


John Stumbles
......................................................................
#!/usr/bin/perl

use warnings;
use strict;
use HTML::TreeBuilder 2.97;
use LWP::UserAgent;

parse_contents (get_page());

sub get_page {
my $ua = LWP::UserAgent->new ;
# 'dsl' is in my /etc/hosts, otherwise us IP address of your DSL
# router (192.168. etc private IP address as seen from connected PC)
$ua->credentials(
'dsl:80', # note 1
'Linksys BEFW11S4', # note 2
'foo', # DSL login user name
'bar' # DSL login passwd
) ;
my $request = HTTP::Request->new(
GET => 'http://dsl/Status.htm' # note 3
) ;
my $response = $ua->request( $request ) ;
unless($response->is_success) {
warn "No response: ", $response->status_line, "\n";
return;
}
return $response->content ;
}
# notes:
# 1 'dsl' in /etc/hosts is IP address (on private 192.168 network)
# of my DSL box
# 2 is string in web login box
# "Enter username and password for Linksys BEFW11S4 ..."
# 3 page containing public-facing IP address of DSL

sub parse_contents {
# this does the dirty work taking apart the HTML returned from the web page
my $page_contents = shift or die "No contents returned from page\n";
my $tree = HTML::TreeBuilder->new();
$tree->parse($page_contents);

my $table = ( $tree->look_down('_tag','table') )[3];
my $row = ( $table->look_down('_tag', 'tr' ) )[10];
my $inet_table = ( $row->look_down('_tag', 'td') )[0];
my $ipadd_row = ( $inet_table->look_down('_tag', 'tr' ) )[0];
my $ipadd_col = ( $ipadd_row->look_down('_tag', 'td' ) )[1];
#$ipadd_col->dump(); # debug
print "\t", $ipadd_col->as_text, "\n";
$tree->eof;
}

__END__
sub dump_contents {
my $page_contents = shift or die "No contents returned from page\n";
my $tree = HTML::TreeBuilder->new();
$tree->parse($page_contents);
$tree->dump();
$tree->eof;
}


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • Re: Connecting a user to AOL (anything I should know?!)
    ... Are you telling me somebody actually managed to Pay for broadband, ... that DSL seems to have not been provisioned on her ... called "MAC Cloning".. ... MAC for the NAT Router to use.. ...
    (uk.comp.homebuilt)
  • Re: 2 wireless routers
    ... Linksys router, and with the help of Usenet, figured out how to set ... it up with DSL. ... Well I now put a wireless card in my niece's computer. ...
    (alt.comp.hardware.pc-homebuilt)
  • Re: Simultaneous DSL and cable modem access on a SBS network...sorf ot.
    ... Your existing router would be surplus to requirements. ... Cable connection. ... I have my MX records pointing to the DSL line, ... The server and the fax (the line the DSL modem ...
    (microsoft.public.windows.server.sbs)
  • Re: Simultaneous DSL and cable modem access on a SBS network...sorf ot.
    ... Your existing router would be surplus to requirements. ... Cable connection. ... I have my MX records pointing to the DSL line, as primary, ... The server and the fax (the line the DSL modem ...
    (microsoft.public.windows.server.sbs)
  • Re: home network, DSL, and router?
    ... I have used D-Link and Linksys routers with a mixed PC-Mac network. ... I think they work the same, but with one difference: My DSL provider ... go with the router that they recommend. ... but also be able to have all computers capable of accessing the DSL ...
    (comp.sys.mac.comm)