meetn2veg has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Resolving basic info from IP address
by arthas (Hermit) on Aug 19, 2003 at 12:28 UTC

    Hi!

    Presuming that by "basic info" you mean the hostname associated with that IP, you can use gethostbyaddr function, or the Net::DNS module.

    If, instead, you want to know where the host with that IP address is located, you can try the module Net::Traceroute or Net::Traceroute::PurePerl (the last one is in pure Perl, it doesn't use XS). Even when you trace the host, it might be difficult for you to know where it's phisically located: you'll either need a visual traceroute, or a whois query for that IP address on the ARIN database, to know that; Net::Whois should be helpful in this task.

    Michele.

Re: Resolving basic info from IP address
by phydeauxarff (Priest) on Aug 19, 2003 at 15:58 UTC
    Do you mean infromation about who is authoritative for the address??

    If so, Net::Whois::IP will give you that info

    #!/usr/bin/perl -w use strict; use Net::Whois::IP qw(whoisip_query); my $ip = "206.157.230.50"; my ($response,$array_of_responses) = whoisip_query($ip); foreach my $key (keys%$response) { print "$key - ", $response->{$key}, "\n" }
Re: Resolving basic info from IP address
by ctilmes (Vicar) on Aug 19, 2003 at 11:26 UTC
    Not sure exactly what you are looking for, but you can get more information from an IP address with Net::DNS.

    getbyaddr might also be of use.

Re: Resolving basic info from IP address
by Abigail-II (Bishop) on Aug 19, 2003 at 11:03 UTC
    What is the basic info from an IP address?

    Abigail

Re: Resolving basic info from IP address
by bear0053 (Hermit) on Aug 19, 2003 at 17:40 UTC
    another alternative is to use javascript to retrieve user information associated with the ip's machine then send that to a perl script where the information is manipulated. use the <img> tag in a web page to capture the information and send it to a perl script. You will probably want the perl script to return a 1x1 pixel blank image so it works properly.
    <SCRIPT language=javascript> //<!--var x; x=""; x+="<img src='http://yoursite/cgi-bin/capture.cgi?page="; x+=escape(location.pathname)+"&ref="+escape(document.referrer)+"&ua="+ +escape(navigator.userAgent)+"&plat="; x+=escape(navigator.platform)+"&cooks="+escape(navigator.cookieEnabled +)+"&cpu="; x+=escape(navigator.cpuClass)+"&java="+escape(navigator.javaEnabled()) ++"'>"; document.write(x); //--> </script>
    this will capture several machine specific details that can be parsed by your perl program. Then in the capture.cgi you will want to simple use the ENV var to retrieve the ip address as you probably were.