#!/usr/bin/perl # This is a perl version of Robin Keir's IP2 at http://keir.net/ip2.html # it gets your Wan IP address and provate IP address if you have one # # This script is for GNU/linux and BSD if you are running windows, use Robin Keir's # program at the site above. # # This script will print out your WAN address and name as seen from a host outside # your internal network # This is useful for those behind a NAT router and need to know the Internet view of # your host, useful for various filesharing apps and IRC stuff # # The following is a list of servers you can use/try if you need to substitute # the default ecerami.com address # # http://ecerami.com/servlet/coreservlets.ShowCGIVariables # http://www.sanford.com/introcgi/cgi-bin/environment-example.pl?something # http://www.mueloliva.es/cgi-bin/variables.cgi?'0024' # http://inetarena.com/cgi-bin/environment.pl?this=that # http://curry.edschool.virginia.edu/go/www_uses/demos/cgi-test.html # http://www.cfhub.com/examples/cgi/ # # This script was created by Douglas Clinton declinton@sympatico.ca # It is disrtibuted inder the GNU GPL if it doesnt work send me an email # If you think that this script has damaged your computer get a brain scan...it can't # # Douglas Clinton use LWP::Simple; # First lets get the info we need from our favorite site @url=get("http://ecerami.com/servlet/coreservlets.ShowCGIVariables"); # This section Finds the match for the WAN IP foreach $i (@url) { if ($i =~ /(\d+)(\.\d+){3}/) { @stuff = $i; #print "$i"; $string = $i; $string =~ s/<([^>]|\n)*>//g ; # removes html tags @stuff = $string; #print "\n$string"; } } @words = split " ", $string; $raw_addr = $words[13]; $raw_name = $words[14]; $clean_addr = substr($raw_addr, 11, 13); # this next line prints the your WAN address print "$clean_addr\n"; $clean_name = substr($raw_name, 11, 45); # this nest line prints your WAN name print "$clean_name\n";