Geolocation by IP Address

Determining geographic locations based on Internet IP offers localization services and brings together user communities without the need for GPS receivers or complicated configuration switching.

The Internet has become a collection of resources meant to appeal to a large general audience. Although this multitude of information has been a great boon, it also has diluted the importance of geographically localized information. Offering the ability for Internet users to garner information based on geographic location can decrease search times and increase visibility of local establishments. Similarly, user communities and chat-rooms can be enhanced through knowing the locations (and therefore, local times, weather conditions and news events) of their members as they roam the globe. It is possible to provide user services in applications and Web sites without the need for users to carry GPS receivers or even to know where they themselves are.

Geolocation by IP address is the technique of determining a user's geographic latitude, longitude and, by inference, city, region and nation by comparing the user's public Internet IP address with known locations of other electronically neighboring servers and routers. This article presents some of the reasons for and benefits of using geolocation through IP address, as well as several techniques for applying this technology to an application, Web site or user community.

Why Geolocation?

The benefits of geolocation may sound complex, but a simple example may help illustrate the possibilities. Consider a traveling businessman currently on the road to San Francisco. After checking into his hotel, he pulls out his laptop and hops onto the wireless Internet access point provided by the hotel. He opens his chat program as well as a Web browser. His friends and family see from his chat profile that he currently is near Golden Gate Park. Consequently, they can determine his local time. By pulling up a Web browser, furthermore, the businessman can do a localized search to find nearby restaurants and theaters.

Without having to know the address of the hotel he's staying in, the chat program and Web pages can determine his location based on the Internet address through which he is connecting. The following week, when he has returned to his home in Florida, he uses his laptop to log into a chat program, and his chat profile correctly places him in his home city. There is no need to change computer configurations, remember addresses or even be aware, as the user, that you are benefitting from geolocation services.

Possible applications for geolocation by IP address exist for Weblogs, chat programs, user communities, forums, distributed computing environments, security, urban mapping and network robustness. We encourage you to find out what applications and Web sites currently employ geolocation or could be enhanced by adding support.

Although several methods of geographically locating an individual currently exist, each system has cost and other detriments that make them technology prohibitive in computing environments. GPS is limited by line-of-sight to the constellation of satellites in Earth's orbit, which severely limits locating systems in cities, due to high buildings, and indoors, due to complete overhead blockage. Several projects have been started to install sensors or to use broadcast television signals (see Resources) to provide for urban and indoor geolocation. Unfortunately, these solutions require much money to cover installation of new infrastructure and devices, and these services are not supported widely yet.

By contrast, these environments already are witnessing a growing trend of installing wireless access points (AP). Airports, cafes, offices and city neighborhoods all have begun installing wireless APs to provide Internet access to wireless devices. Using this available and symbiotic infrastructure, geolocation by IP address can be implemented immediately.

Geolocation Standards and Services

As discussed below, several RFC proposals have been made by the Internet Engineering Task Force (IETF) that aim to provide geolocation resources and infrastructure. However, these standards have met with little support from users and administrators. To date, there has not been much interest in providing user location tracking and automatic localization services. Several companies now offer pay-per-use services for determining location by IP. These services can be expensive, however, and don't necessarily offer the kind of functionality a programmer may want when designing his or her Web site or application.

Several years ago, CAIDA, the Cooperative Association for Internet Data Analysis, began a geolocation by IP address effort called NetGeo. This system was a publicly accessible database of geographically located IP addresses. Through the use of many complex rules, the NetGeo database slowly filled and was corrected for the location of IP addresses. The project has been stopped, however, and the technology was licensed to new partners. However, the database still is available, although several years old, and provides a good resource for determining rough locations.

To query the NetGeo database, an HTTP request is made with the query IP address, like this:


--
$ http://netgeo.caida.org/perl/netgeo.cgi?target=192.168.0.1 
VERSION=1.0
TARGET: 192.168.0.1
NAME: IANA-CBLK1
NUMBER: 192.168.0.0 - 192.168.255.255
CITY: MARINA DEL REY
STATE: CALIFORNIA
COUNTRY: US
LAT: 33.98
LONG: -118.45
LAT_LONG_GRAN: City
LAST_UPDATED: 16-May-2001
NIC: ARIN
LOOKUP_TYPE: Block Allocation
RATING: 
DOMAIN_GUESS: iana.org
STATUS: OK
--

As you can see, the NetGeo response includes the city, state, country, latitude and longitude of the IP address in question. Furthermore, the granularity (LAT_LONG_GRAN) also is estimated to give some idea about the accuracy of the location. This accuracy also can be deduced from the LAST_UPDATED field. Obviously, the older the update, the more likely it is that the location has changed. This is true especially for IP addresses assigned to residential customers, as companies holding these addresses are in constant flux.

In order to make this database useful to an application or Web site, we need to be able to make the request through some programming interface. Several existing packages assist in retrieving information from the NetGeo database. The PEAR system has a PHP package (see Resources), and a PERL module, CAIDA::NetGeo::Client, is available. However, it is a relatively straightforward task to make a request in whatever language you are using for your application or service. For example, a function in PHP for getting and parsing the NetGeo response looks like this:


--
1: function getLocationCaidaNetGeo($ip)
2: { 
3: $NetGeoURL = "http://netgeo.caida.org/perl/netgeo.cgi?target=".$ip; 
4:  
5: if($NetGeoFP = fopen($NetGeoURL,r))
6: { 
7:         ob_start();
8: 
9:         fpassthru($NetGeoFP);
10:         $NetGeoHTML = ob_get_contents();
11:         ob_end_clean();
12:
13: fclose($NetGeoFP);
14: }
15: preg_match ("/LAT:(.*)/i", $NetGeoHTML, $temp) or die("Could not find element LAT");
16: $location[0] = $temp[1];
17: preg_match ("/LONG:(.*)/i", $NetGeoHTML, $temp) or die("Could not find element LONG");
18: $location[1] = $temp[1];
19:
20: return $location;
21: }
--

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Is it possible?Suppose,How

save fuel's picture

Is it possible?Suppose,How can i know from where any E-mail has came?Is there any web-site to find out from where the mail has came?

Free Email Header Tracer at ip2location.com

kayla's picture

Try this, is a free service. :)
Just paste the email header and this site helps to check where is the email origin.
http://www.ip2location.com/emailtracer.aspx

the best ip location

Anonymous's picture

my best ip checker proxy checker

San Francisco

Anonymous's picture

How could I tell when someone from San Francisco hits my site at:
Mister Archer: Undiscovered San Francisco Revealed?

Thank you!

need help with incorrect info on google

Anonymous's picture

Hi,
nice Article and i got more info for this article and everybody visit my site and comments for my Article.www.adnpost.com

when i first created the site i had no clue what was going on and tagged some SEO garbage in the discription as well as saved my site as rossgoodmanphotography.com with out the www. about a month ago i changed the discription in hopes that google would re-crawl and fix the information. i read i should submit a site map so i did but had to submit a new site with the WWW. in front. well google has re-crawled the site but nothing has changed when i perform the search for ross goodman photography. i am soo confused as to what to do about it, any help would be great thank you

usercenter

Anonymous's picture

API für php in xml

Anonymous's picture

Good site

Anonymous's picture

I have to say... this is the first site that gives the right location of my IP address. All others are wrong (next big city around me).

IP Address Geolocation

Anonymous's picture

I found a new site to check out IP Address details through
www.ipaddressgeolocation.com

check Ip of Gmx/ Scammer?

Anonymous's picture

Hi,
I want to locate the adress of someone,maybe a scammer. IP is located in germany as the host is gmx.de.Is it possible to see in the mail,if it comes from germany or russia.
rom anfisa.s@gmx.de Tue Nov 10 15:44:35 2009
X-Apparently-To: pinasystems24@yahoo.de via 87.248.110.125; Tue, 10 Nov 2009 09:47:37 -0800
Return-Path:
X-YMailISG: x6XWZjcWLDtCbLMBoXtrt12aX1AVF89s.hd5pD0eA1ee9_3ovuor.vjAAwdYa1_OkSnCgdWhMUAZXCflX7R_RpTyUu3ZrX_hEQO7mHDdBOtgs5zw5FGO3ERcBBZxmeFwlZz_M4TZiM0RmXg2zGsL6BMTUZC7FjGSDfRlTAUmMt8PAp.aIAH3iNYIcd86JlBXvDT_C0ptYCV9_Rp.pksDt7Va738S_IqfD8WTPwPvOeAx8zQcbU5hofyAVF1U6pMT5NLTfJgGwfdh4jLcLbXT6T.CKUHxqGjjOcueBL2jMkG7O9c5qEieEiTIQPXLzF64LMMAEnSQh_NFm8i2hujUyzILkUeIGlfikFJIBNtNph_R77mLmKjbtdjIZc6aRobLJalZhVFp6U_r8Xe3MCaXbdlyOl7VEbztWNoIfsmcF98-
X-Originating-IP: [213.165.64.20]
Authentication-Results: mta132.mail.sp2.yahoo.com from=gmx.de; domainkeys=neutral (no sig); from=gmx.de; dkim=neutral (no sig)
Received: from 127.0.0.1 (HELO mail.gmx.net) (213.165.64.20)
by mta132.mail.sp2.yahoo.com with SMTP; Tue, 10 Nov 2009 09:47:37 -0800
Received: (qmail invoked by alias); 10 Nov 2009 17:47:28 -0000
Received: from HSI-KBW-095-208-174-017.hsi5.kabel-badenwuerttemberg.de (EHLO comp) [95.208.174.17]
by mail.gmx.net (mp013) with SMTP; 10 Nov 2009 18:47:28 +0100
X-Authenticated: #58738999
X-Provags-ID: V01U2FsdGVkX1++0sxFz5y+oquEYzLgvtyXQ32Bkx8AK8Qthdlybt
V0TAN5UzWhz5Wo
Date: Tue, 10 Nov 2009 18:44:35 +0300
From: anfisa.s@gmx.de
X-Mailer: The Bat! (v3.99.3) Professional
X-Priority: 3 (Normal)
Message-ID: <661978319.20091110184435@gmx.de>
To: =?iso-8859-1?Q?Sebastian_B=F6=DF?=
Subject: Guten Tag
In-Reply-To: <860504.55087.qm@web28310.mail.ukl.yahoo.com>
References: <446603.25418.qm@web28305.mail.ukl.yahoo.com> <1403195454.20091105184430@gmx.de> <274517.18777.qm@web28303.mail.ukl.yahoo.com> <92284562.20091106172448@gmx.de> <858029.45638.qm@web28306.mail.ukl.yahoo.com> <1853119150.20091107184127@gmx.de> <629756.68244.qm@web28316.mail.ukl.yahoo.com> <18010060205.20091109172601@gmx.de> <860504.55087.qm@web28310.mail.ukl.yahoo.com>
MIME-Version: 1.0
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-Y-GMX-Trusted: 0
X-FuHaFi: 0.71
Content-Length: 2814

HELP!

Anonymous's picture

Look it's all a very good idea and all but i must be missing somthing.
What do i do when im sitting in england and my IP says that i am in austrailia! I need to change the setting becasue all UK websites that i want to access are not letting me. Please could someone help me, and just tell me simply how to change my location so i can visit uk sites again

Cheers

I found a new site

Anonymous's picture

I found a new site to check out IP Address details through
http://www.ipaddressgeolocation.com

hello I found a new site to

Anonymous's picture

hello
I found a new site to check out IP Address details through www.IpAddressGeolocation.com

hai, You gave a benefits of

Anonymous's picture

hai,
You gave a benefits of geolocation using the ip address.It is nice.
But i collected the details of ip address and location from this ip-details.It also used to finding domain host,broadband speed,and latitude and longitude of the location.It is really helpful for me.

services

Misafir's picture

There are a so many services that has such function.

Is it possible?

sandeep's picture

Sir/Madam,

My name is Sandeep.I am staying in Mumbai(India-Maharashtra).I want some help from you.

Is it possible?Suppose,How can i know from where any E-mail has came?Is there any web-site to find out from where the mail has came?

Thanks!
Sandy.

reply email tracing

Anonymous's picture

sandeep, all the tracing information for how the email was routed is in the emails meta data...all of it.
so even if the sender changes the name and service name manually or via bot...you can view and backtrack to the sender via the ip trail. Do a quick internet search for how to do this if you do not know how...a geoip type application/service can let you follow how the email got to you in reverse.
I recommend you do the lookups in reverse rather than just look at the last ip address as it may be a onion router relay or some such. If you hit an onion router or anonymizer well you will need to do some more deeper sleuthing.

Don't know why my previous

geoplugin's picture

Don't know why my previous post was deleted, but it's worth pointing out that this article is old and netgeo.caida.org is no longer maintained.

For easy geolocation without any software requirements, geoPlugin offers a free webservice.

The geolocation examples page gives ideas on how to use the service, with detailed highlighted code.

IP Address Lookup

IP Address Lookup's picture

The best I know, is IP Address Lookup ! I am using it since I discovered it. It is very accurate.

needs more testing

prabu's picture

"Could not open postal code file"

Free country geolocation

Anonymous's picture

IP to city level geo info with Google map

Anonymous's picture

IpGeoInfo.com provides very easy to use city level geolocation service. It also shows the location on the google map. You cal also create links of the type http://ipgeoinfo.com/?ip=YOUR_IP in any web page etc easy access to the service.

bloody annoying , language by geolocation

winsute@yahoo.com.au's picture

I hate it. My browser can send my language preferences. And the websites ignore them simply because i am in some other country. I am an english speaker, and I want my web pages (yes you google and myspace) in ENGLISH!!!
If I wanted them in german, i'd set my system preferences or browser language preferences to german. Having regions in what is and should be an international internet is completely wrong.
And i would complain about the same thing if i was japanese traveling in England or America and getting english websites back. Or a spanish person traveling in norway. Hell, why the hell would I, as a spanish speaker, want to get my web pages viewed in Norwegian, just because I am traveling in that country.

IP Address Allocation Trend 2008

Jim KN's picture

I found the following report interesting about the trends of IP address allocation in 2007-2008. Some countries are growing at very fast rate.

http://www.ip2location.com/ip2location-internet-ip-address-2008-report.aspx

ip location free service

Anonymous's picture

Good way to determine the ip location of a user with this ip-location free service.

D.A.

There are a so many services

Alex T.'s picture

There are a so many services that has such function. But I created my own to get the easiest way to determine geo location.

Beta?

Anonymous's picture

Alex,
Your IP tool doesn't work. I'm nowhere NEAR where it says I am.

There are a so many services

Alex T.'s picture

There are a so many services that has such function. But I created my own to get the easiest way to determine geo location.

Could not open country code file

tonykbl's picture

When i go to view the example i get the following error 'Could not open country code file'

Free geolocation 'widget'

ned96's picture

Check out http://freeipservices.com. It runs on Amazon's ec2 infrastructure and you can use it as a javascript widget on your web page to track each and every customer who comes to your site. It gives latitude, longitude, city, state/province and country information.

Potentials of Geolocation Technique

portrait artist's picture

How effect is this technique? Isn’t it that one can manually change his or her IP? I’ve known that some webmasters especially the ones involved in marketing and advertising keep a record of free IPs in their file and manually changes their computer IP into another one. This new IP is registered as coming from someone located in Germany when actually the webmaster is from India. How can geolocation solve this?

RSS feeds?

gifts's picture

I'm seeing something, that I think, is pretty interesting with the idea of geolocations. Perhaps you can have some sort of “RSS feed

it's not always language

spenser's picture

For those jumping up and down about geolocation causing content to be delivered in other than their preferred language, yes, that is an improper use of the data since your browser sends an explicit preference. However, that aside, the data has uses. For example, some service providers try to point the user to the closest server in an attempt to provide faster service. That has nothing to do with privacy or language.

could not open postal code

Anonymous's picture

could not open postal code file

need help on IP

Anonymous's picture

what am i to do ?

someone is trying to find out my IP number. is this possible?
what can he do when he gets my Ip number?

yes it is possible.for

Anonymous's picture

yes it is possible.
for instance, if you are chatting with me then by running tracert command in command prompt in windows operating system, i could the list of ip address of the machine to which i'm connected now. then by simply closing all the other applications except the chatting application, i could find out your ip address

need help on IP

Anonymous's picture

what am i to do ?

someone is trying to find out my IP number. is this possible?
what can he do when he gets my Ip number?

free geolocation

Jack's picture

IPligence has a free geolocation database called IPligence community edition, it allows to find the ip location of ip addresses and its free to use for non commercial activities or develpment, it can be downloaded from this link:

http://www.ipligence.com/en/products/community.php

correct link

Anonymous's picture

this one seems to work http://www.ipligence.com/community

I prefer the IP Locate

Paul.J's picture

I prefer the IP Locate service. Uses that ajax so its much smoothing. Happy new year all!

Find out your ip address and map it on google map

Puneet's picture

hi all,
use this link to find out your geographical location based on ip address
www.geo-location.com/cgi-bin/index.cgi

Another IP to location

Anonymous's picture

Another website that locates an ip address on a google map. It seems you can also enter a domain/website and find out where it is hosted .... interesting.

www.geo-ip.info

geolocation

Zsuzsanna Vizi's picture

"Point your Web browser of choice here, and see how accurate or inaccurate the current results are."

The result is the following:
Could not open postal code file

I'm seeing article, that I

proxy site's picture

I'm seeing article, that I think, is charming interesting with the idea of geolocations. Perhaps you can have approximately sort of “RSS fuel up

Hostip.info ..... it gets

Anonymous's picture

Hostip.info ..... it gets the country right.... but every time i refresh i get a new city name

strange! i'd rather you got it wrong once rather than guessing it wrong constantly

Geolocation by IP address is

Anonymous's picture

Geolocation by IP address is a terrible practice. I, for example, am a US Citizen traveling in Japan. I do NOT speak or read Japanese. However, many web sites (google, skype, rhapsody, to name a few, as well as banner ads) redirect me to their Japanese web sites. Not only does this not do me any good at all, but I can't find my way back to an English written web site and when I do, it just redirects me back to the Japanese one as soon as I click a link! It's terribly frustrating, and in today's world of business, with global travelers and military deployed world-wide, the very idea of using one's IP address to determine language is laughable. Really, people, if you are going to link language to anything, you should be taking advantage of the protocol set forth specifically for doing so: the system user preference for language. I realize that while within one's own geographical confines, this IP binding practice may be beneficial, it is detrimental to the point of driving the end user insane outside of his or her native geographical region. Let's stop letting technology control us, and take back the reigns, because after all, technology is supposed to serve us, not the other way around.

It's a great Idea

Anonymous's picture

I travel a lot around Asia and nothing annoys me more than a foreigner who complains about things not being in English. If you don't intend to learn the language and culture then go home. As far as identifying IPs for specific countries, its a great idea, and if you want the world to change orbit for your arrogant ways well you won't find much sympathy on your travels so your post is pointless. A web page is going to guess what and how many langauges you can speak? How about you live up to being a global citizen and learn another language at least.

Read RFC 2616

Anonymous's picture

Before criticizing someone for asking that languages preferences, where possible, be respected, you need to read RFC 2616, the HTTP specification. It includes a request header named Accept-Language, which lists the languages a user can understand or is otherwise willing to accept, including ordering the languages by the user's preference.

It is not acceptable for sites such as Google or Yahoo (listed as well-known examples, not a criticism of what they actually do) to ignore the Accept-Language header and base the language used in a response on a guess of the user's geographic location. The reason it is not acceptable is that such behavior violates the protocol specification.

If you are an American in Japan and using Yahoo mail, you
would not want the buttons and other controls to be labeled
in Japanese if you did not know Japanese.

How about getting off your

Anonymous's picture

How about getting off your arrogant pedestal and admitting that maybe it's better that the technology serves the user rather than the other way around? Not everyone that's even a citizen or resident of a given country wants to see the majority language in that country just because their IP address happens to be identified as being in that region. (Think Spanish-speakers or Chinese-speakers in the US--it doesn't mean they don't speak the language, just that they prefer their own, for whatever personal or cultural reasons.) There is a specific setting in the browser that tells the server which language the user prefers. This has a very high probability of being correct. The IP address has a very high chance of being incorrect in this regard. Why should the server ignore the explicit directive from the user's own browser and decide that they should see what it thinks their IP address belongs to?

It really isn't a terrible

Anonymous's picture

It really isn't a terrible practice. If you truely are an international traveler you should get yourself a proxy and quit worrying about region specific websites. Don't blame the technology when you don't understand, or take the time to utilize effectively.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix