Solved

Deriving geographic data from an IP address

Posted on 2004-08-09
7
353 Views
Last Modified: 2010-10-05
Is there a way to determine geographic information in by parsing an IP address? How is an IP address created? Do the numbers have any significance in terms of geographic location? If there is a database that defines the different parts of an IP address, where is it?

Basically I am trying to determine the location of web users and dynamically displaying content that is local to them by analyzing thier IP address.
0
Comment
Question by:paulfryer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 11

Expert Comment

by:sciber_dude
ID: 11755701
I am not sure if you can do that...

but here is some information ... http://www.private.org.il/IP2geo.html

:) SD
0
 
LVL 11

Expert Comment

by:sciber_dude
ID: 11755780
oops! I guess i have to take that back.. please scroll down to the very bottom of this page. http://www.vterrain.org/Culture/geocoding.html

:) SD
0
 
LVL 1

Expert Comment

by:johanmulder
ID: 11756945
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 1

Expert Comment

by:johanmulder
ID: 11757178
No, Im sorry for posting this link (it's linking to a commercial website).
A better way is to use the whois requests from the Ripe, Arin or Apnic Whois Databases.
For more info check out http://msv.dk/ms470.asp, which shows you a good example of the request returns.

Now the tricky part to read the needed information. In PHP it will be something like this:

<?php
$ipaddr = "212.33.23.78"; //actual IP
$fp = fsockopen("whois.ripe.net", 43, $errstr, $errno, 30);

if(!$fp)
    echo "$errno: $errstr";
else
{
    socket_set_timeout($fp, 10);
    fwrite($fp, $ipaddr);
    while (!feof($fp)){ $ipinfo .= fgets($fp); }  
}
fclose($fp);
echo nl2br($ipinfo);
?>

The results will be stored in the $ipinfo variable.
Well, i think you can try this one.
0
 
LVL 13

Accepted Solution

by:
davidlars99 earned 500 total points
ID: 11758649
of course there is, here you go http://www.geobytes.com/IpLocator.htm
you just have to pay a small fee and remmember it takes an extra bandwidth and damn much, trust me I've used it, besides everuthing it's just great!

cheers!
 dave
0
 
LVL 26

Expert Comment

by:rdcpro
ID: 11758724
I'm not sure what good the whois database is going to do...it might get you the right culture, and it might not.  For example, my IP address returns:

OrgName:    U S WEST Internet Services
OrgID:      USW
Address:    950 17th Street
Address:    Suite 1900
City:       Denver
StateProv:  CO
PostalCode: 80202
Country:    US

NetRange:   65.100.0.0 - 65.103.255.255
CIDR:       65.100.0.0/14
NetName:    USW-INTERACT99-2BLK
NetHandle:  NET-65-100-0-0-1
Parent:     NET-65-0-0-0-0
NetType:    Direct Allocation
NameServer: NS1.USWEST.NET
NameServer: NS2.DNVR.USWEST.NET
NameServer: NS3.MN.USWEST.NET
Comment:    ADDRESSES WITHIN THIS BLOCK ARE NON-PORTABLE
RegDate:    2001-01-03
Updated:    2002-08-12

TechHandle: ZU24-ARIN
TechName:   U S WEST ISOps
TechPhone:  +1-612-664-4689
TechEmail:  abuse@uswest.net

OrgAbuseHandle: QIA2-ARIN
OrgAbuseName:   Qwest IP Abuse
OrgAbusePhone:  +1-877-886-6515
OrgAbuseEmail:  abuse@qwest.net

OrgNOCHandle: QIN-ARIN
OrgNOCName:   Qwest IP NOC
OrgNOCPhone:  +1-877-886-6515
OrgNOCEmail:  support@qwestip.net

OrgTechHandle: QIA-ARIN
OrgTechName:   Qwest IP Admin
OrgTechPhone:  +1-877-886-6515
OrgTechEmail:  ipadmin@qwest.com

# ARIN WHOIS database, last updated 2004-08-08 19:10
# Enter ? for additional hints on searching ARIN's WHOIS database.

Which might tell you I'm American, but you'd know that because you searched Arin, the US DB.  If you search the Europe DB, I'll bet it's a lot less likely to indicate the correct country.  Even then, you don't know a lot about the culture settings of the local machine.  You pretty much need to use one of the commercial/semicommerical IP lookup products, if that's the way you're going to do it.

A better way is to first look if the HTTP_ACCEPT_LANGUAGE request header is set.  

Also, there are lots of BrowserCap products out there.  BrowserHawk tells me:

Language  English
LangUser  en-us
LangSystem  en-us

BrowserHawk also uses IP lookup on an in-memory DB, but maybe you don't really need that.  And I'm sure there are open source products...

The best bet is to look at a number of things.  If HTTP_ACCEPT_LANGUAGE is set, then use that.  If not, use an IP lookup...etc.

Regards,
Mike Sharp
0
 
LVL 2

Expert Comment

by:izzeddeen
ID: 11778862
According to my experience, IPs change from time to time.

So it's possible that an IP belongs to Country X this year, and next year it becomes in Country Y.

There are different online services that provide you with up to date IP geography.

http://ip-to-country.webhosting.info/ is one of those site in which you can benfit from their database in two ways:

1. Either you download their free database of IP classes and their distribution.
2. Or you subscribe to connect to their web service API to connect to them dynamically and get the IP information fresh at the run time of your site.

Hope this helps
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa‚Ķ
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question