IP Addresses

faithless1 used Ask the Experts™

I have a file with a list of IP addresses on each row. I'm looking for a script which will output a file with a list of associated States, Cities and Zip Codes. If there are limitations on the output as far as GEO location, as much information on each IP address would be ideal.

Thank you.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
do you already have the data for the mapping?  If not you could purchase it here They also have a perl api that can be used
sorry didn't fully read you post - ignore my previous answer
first you need to get a source that will have the data that maps the ip address to a location, I don't know of any free places for this information. - my first post has a source to purchase on
Once you have that then you can begin the process of mapping your ip addresses to City State and Zip, knowing that this information will only be as accurate as your data.  For instance the ip address of a person browsing the internet through his ISP may indicate that he is located in Kansas, even though he lives in Wisconsin.

After you get the State Address and Zip you can get additonal GEO information using the google maps api or bing api.

Dave BaldwinFixer of Problems
Most Valuable Expert 2014

MaxMind offers the data and APIs http://www.maxmind.com/app/geolitecity .  You should know that IPs are assigned to ISPs and hosting companies.  An IP that is assigned to AT&T could be almost anywhere in the US but you will get back the AT&T address associated with it, not the user address.  The people that have more accurate info are collecting names and addresses with the IP addresses, usually by asking for it.  I don't know of any of those that are freely available.
Hi fl1,

The best I can offer is that you install Perl's Net::Whois::Raw from cpan.org, then run this line of code:
    $who = whois("$ip");
for each IP address, and then have fun trying to extract the location data you require from $who.

Before writing a script, suggest you start by running something like this:
    perl -MNet::Whois::Raw -e 'print whois("")'
from the command line, to see if the output is going to be useful to you.
If you get an error like this:
    Can't locate Net/Whois/Raw.pm...
then make sure the module is installed, then try this:
    perl -I/home/your-account/perl/usr/lib/perl5/site_perl/5.8.8 -MNet::Whois::Raw -e 'print whois("")'
or whatever the path to installed modules is.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial