Avatar of faithless1
faithless1
 asked on

IP Addresses

Hello,

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.
Perl

Avatar of undefined
Last Comment
tel2

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
mwochnick

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
mwochnick

sorry didn't fully read you post - ignore my previous answer
mwochnick

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 Baldwin

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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
tel2

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("123.45.67.89")'
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("123.45.67.89")'
or whatever the path to installed modules is.