From owner-freebsd-questions@FreeBSD.ORG Wed Sep 3 15:23:06 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 46C5816A4BF for ; Wed, 3 Sep 2003 15:23:06 -0700 (PDT) Received: from mta01-svc.ntlworld.com (mta01-svc.ntlworld.com [62.253.162.41]) by mx1.FreeBSD.org (Postfix) with ESMTP id 90A5043FB1 for ; Wed, 3 Sep 2003 15:23:04 -0700 (PDT) (envelope-from merv@merv.org.uk) Received: from FreeBSD.merv.org.uk ([81.100.88.98]) by mta01-svc.ntlworld.comESMTP <20030903222304.WTOK19218.mta01-svc.ntlworld.com@FreeBSD.merv.org.uk>; Wed, 3 Sep 2003 23:23:04 +0100 Received: by FreeBSD.merv.org.uk (Postfix, from userid 1001) id 8B0F3A2F; Wed, 3 Sep 2003 23:23:03 +0100 (BST) From: merv Organization: Home To: "Drew Tomlinson" , "FreeBSD Questions" Date: Wed, 3 Sep 2003 23:23:03 +0100 User-Agent: KMail/1.5.3 References: <019101c37248$ffd50c30$6e2a6ba5@lc.ca.gov> In-Reply-To: <019101c37248$ffd50c30$6e2a6ba5@lc.ca.gov> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200309032323.03378.merv@merv.org.uk> Subject: Re: How to Get Public IP From LinkSys Router? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Sep 2003 22:23:06 -0000 Drew, I use a perl script to get mine, see below. It may point you in the right direction. You will need to change this script to use your SMTP server, your email address and the IP address of your router. ~~~ #!/usr/bin/perl # Dynamic DNS, style program. # # Usage : Ask the Router for my Dynamic WAN IP addres and # then mail the result to me. # # Future : Build HTML page and post it to my Web site. # # perl -MCPAN -e 'install Bundle::LWP' # use LWP::UserAgent; use HTTP::Cookies; use Net::SMTP; # # Send Mail to Me with my IP address. # #Array of people to tell @ToList = qw(my_addr@somplace.com another_user@somplace.com ); sub send_mail() { $from="FreeBSD"; $srvr=""; $smtp = Net::SMTP->new($srvr); foreach $to (@ToList) { $smtp->mail($from); $smtp->to($to); $smtp->data(); $smtp->datasend("To: Users\n"); $smtp->datasend("\n"); $smtp->datasend("New IP address is :". $ip . "\n\n"); $smtp->dataend(); sleep(1); } $smtp->quit; } #What was the IP address last time, we will save and check. $in_file = "h:/wsh/WANIP_LOG.txt"; $out_file = "h:/wsh/WANIP_LOG.txt"; $linksyspassword = ''; $ua = new LWP::UserAgent; $req = new HTTP::Request GET => 'http:///Status.htm'; $req->authorization_basic('',$linksyspassword); $res = $ua->request($req); if ( $res->is_success ) { @data = split //, $res->as_string; } else { # print "Error: unable to get router's address\n"; exit 1; } foreach $data (@data) { if ( $data =~ /IP Address:/ ) { $data =~ s/<\/td><\/tr>//g; # trim extraneous tags $data =~ s/<(.)*>//; # $ip = $data; # The second IP is what we want. } } #Read in Old WAN IP. open (IN, "<$in_file") || die "Can't open $in_file: $!\n"; undef $/; #Skip end of line marker. $content = ; close(IN); $/ = "\n"; #Restore for normal behaviour later in script if(($content =~ m/$ip/)==0) { send_mail(); } #Save the WAN IP open(OUT, ">$out_file") || die "Can't open $in_file: $!\n"; print OUT "$ip\n"; #print "DSL Gateway $ip \n"; On Wednesday 03 September 2003 7:27 pm, Drew Tomlinson wrote: > I need to get my public IP address from a LinkSys cable router and don't > have any idea where to start. The LinkSys is doing NAT and my FBSD box > in on the private network on the inside. What commands and/or ports are > there that would provide the public IP address from the command line so > I pass the IP to a script? Any ideas? > > Thanks, > > Drew > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org"