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.
Using DNS to Your Advantage

As previously mentioned, the NetGeo database slowly is becoming more inaccurate as IP address blocks change hands in company close-outs and absorptions. Several other tools are available for determining location, however. A description of the NetGeo infrastructure itself (see Resources) presents some of the methods it employed for mapping IP addresses and can be a source of guidance for future projects.

One of the most useful geolocation resources is DNS LOC information, but it is difficult to enforce across the Internet infrastructure. RFC 1876 is the standard that outlines "A Means for Expressing Location Information in the Domain Name System." Specifically, this is done by placing the location information of a server on the DNS registration page. Several popular servers have employed this standard but not enough to be directly useful as of yet.

To check the LOC DNS information of a server, you need to get the LOC type of the host:

$ host -t LOC LOC 37 23 30.900 N 121 59 19.000 W 7.00m 100m 100m 2m

This parses out to 37 degrees 23' 30.900'' North Latitude by 121 degrees 59' 19.000'' West Longitude at 7 meters in altitude, with an approximate size of 100 meters at 100 meters horizontal precision and 2 meters vertical precision. There are several benefits to servers that offer their geographic location in this way. First, if you are connecting from a server that shows its DNS LOC information, determining your geolocation is simple, and applications may use this information without further work, although some verification may be useful. Second, if you are connecting on your second or third bounce through a server that has DNS LOC information, it may be possible to make an estimate of your location based on traffic and ping times. However, it should be obvious that these estimates greatly degrade accuracy.

It also is possible to put the DNS LOC information for your Web site in its registration (see Resources). If more servers come to use LOC information, geolocation accuracy will be much easier to attain.

Sidebar: host

host is a DNS lookup utility that allows users to find out various pieces of information about a host. The simplest use is doing hostname to IP address lookups and the reverse. The reverse, dotted-decimal IPv4 notation, is used for this, and the actual server that hosts the canonical name is returned. The type flag, -t, can be used to obtain specific information from the host record from the name server.

Where There's a Name, There's a Way

Many users hopping onto the Internet probably aren't coming from a major server. In fact, most users don't have a static IP address. Dial-up, cable modems and cell phone connections are assigned a dynamic IP address that may change multiple times in one day or not at all for several weeks. Therefore, it becomes difficult to tie these dynamic addresses to a single location.

To our rescue, these service providers typically provide an internal naming scheme for assigning IP addresses and associating names with these addresses. Typically, the canonical name of an IP address contains the country-code top-level domain (ccTLDs) in a suffix. CN is China, FR is France, RO is Romania and so on. Furthermore, the name even may contain the city or region in which the IP address is located. Often, however, this information is shortened to some name that requires a heuristic to determine. For example, in your service or application, a user may appear to be coming from A whois at this address reveals it is a WideOpenWest account from Michigan. Using some logic, it is possible to deduce that this user is connecting through a server located in Troy, MI, hence the .try. in the canonical name.

Some projects have been started to decipher these addresses (see Resources), and you also can get all of the country codes and associated cities and regions of a country from the IANA Root-Zone Whois Information or the US Geospatial Intelligence Agency, which hosts the GEOnet Names Server (GNS). The GNS has freely available data files on almost all world countries, regions, states and cities, including their sizes, geographic locations and abbreviations, as well as other information.

Information such as that presented on the GNS also can be used to provide users with utilities and services specific to their geographical locations. For example, it is possible to determine a user's local currency, time zone and language. Time zone is especially useful for members of a community or chat group to determine when another friend may be available and on-line.



Comment viewing options

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

Pointing in the wrong direction

Anonymous's picture

Let's not go overboard with the "We are being controlled by our technology" speech.

It is not technology which is foisting the Japanese text on you, but a person who decided it would be a good idea to use geolocation by IP, instead of the user's settings. It is a misapplication of technology. People do that. Technology doesn't apply itself, even when it appears to be automagic.

Geo-IP Location in the Travel Industry

James D Semple's picture

Hi Everyone, I've implemented a solution from MaxMind's free database and added some of my own data/testing also. I think this will work nice for the travel market, since usually a person travelling cares about a metropolitan area rather than a rural town in most cases, heck they may even be lost in a rural town or need to find out what's going on in the big city. A buddy of mine is in Europe now (currently Austria) and tested it out, he said he was in Villach and it pointed him to Vienna instead. A few friends back home in Canada here are being pointed to Toronto (we're outside Toronto) I'm guessing with DSL it goes to Toronto's server. Some point correctly to their city, some not. I expect as the site grows to accept user input as to their location and for people to offer up where they were (it would be nice if everyone had a static ip!) I hope to correct the database to 99.9% reliability someday, but that seems a little unrealistic since like many mentioned some ISPs are not located in the same city irregardless. Check it out where did it send you? You can contact me on MSN if you like what I'm doing and want to talk.

Check out

Anonymous's picture

Check out this:

The example does what the article is talking about.

Better URL for testing

R. Scott Perry's picture

The old URL to test geolocation no longer works. You may want to point people to instead.

Geolocation URL restored

Andy Turner's picture

The link has been restored. It was accidentally moved during a site upgrade. My apologies.

Localisation and You (John Robinson at 1341 Crescent Dr....)

Anonymous's picture

Besides the worrying implications for privacy, I strongly believe on principle that you should not know my true IP nor be able to trace it to a specific geographical location. Geolocation by IP is a prime example of modern software trying so hard to be "smart" that it ends up dumb. My browser (like almost all browsers) will explicitly identify the preferred language and region of my system based upon user-defined choices on the OS-level, and yet, sites like will insist on trying to "guess" my language/country based upon my IP, which is highly variable. Not that I entirely agree with browsers leaking that information in the first place, but it makes much more sense to base the rendering/forwarding of a webpage on OS-level user-defined choices than on a systems guesses based upon IP, especially for those with proxied systems. I do not just dislike modern localisation technologies, I oppose them unreservedly, along with all they represent.

Localisation and You (John Robinson at 1341 Crescent Dr....)

Anonymous's picture

Besides the worrying implications for closed meeting, I strongly pretend on familiarization that you have need to not transmission my offbeat IP nor be able to trace it to a remedy geographical location. Geolocation by IP is a prime example of late software counteractive so close to be "smart" that it ends up duncical. My browser (nonresisting almost all browsers) you name it explicitly identify the preferred language and region of my unify damnabled inlet user-defined choices on the OS-level, and yet, sites nothing loath with total dedication avow on fatiguesome to "fortune-tell" my language/country chemicald make an overture my IP, which is well variable. Not that I entirely acquiesce in with browsers leaking that control signals in the essential chaussee, but it makes much more splash to alloisomer the rendering/forwarding of a webpage on OS-level user-defined choices excepting on a unifys hold ases below contemptd gather IP, remarkably for those with proxied toss togethers. I do not apt dissilver-voiced modish localisation technologies, I oppose them unreservedly, along with all it evidence.

Re:Localisation and You

Sesso Incontri's picture

From geobytes faq "To achieve this we acquire seed data from a number of
sources. All of these sites ask the web surfer to provide their
geographic location, and this location along with the user's IP Address
is forwarded to us as seed data. We then run this data through a series
of algorithms which identify and extract collaborating seed points."

So the process in reverse is a little bit like the RIR whois which
correlates an IP with a provider netblock, except for geo the IP is
correlated with a much more finely granular block or group of IPs
corresponding to a little geographic area.

Incorrect geolocation determination

Pat Plaehn's picture

The geolocation service you provided had me in Bordeaux, Gironde (department), aquitaine (region), France. I am in Dunstable, MA, USA.

me too

Anonymous's picture

It had me in Auckland NZ - I am in Rennes, France!!! Couldn't be more wrong :-)

re:Incorrect geolocation determination

Vaffunculo's picture

99%? It appears that all shows Belleville. Possible, it
is big enough. But, it also seems to show as all
Waterloo. That seems odd, assuming the blocks are all Charter Business
Net assigned. So,I'll speculate a little.

There are many small/very small towns in that area. The IP blocks may be
assigned to a POP that services a general area. So, the machine may not
actally be in Belleville, it may be in a nearby town.

Hello all! Does someone kn

Anonymous's picture

Hello all!

Does someone know a really free database with geolocations? I need something I can download and it should contain the Country and the City for a given IP.

Thanks! :)

This IPs change too fast !

Anonymous's picture

Hi Folks.

This IP-Detection is a great idea. But it is NOT working 8-)))))

I tested different sources - most of them told me, that I was located in Australia 8-)))))) ... well that is about 10.000 Kilometers from my real location.

To lockout people from a country - lets say Thailand - I use "whois -h" and then parse the string I get back. Done in PHP this is much more easier (and quicker) than to rely on this databases.

... but - the Idea is good ... just lacks some "central intelligence database"


Block IP address country/region

naveen's picture

If you can help me tell how can we block IP region/country and state wise worlwide.
Using which language is more accurate and better.
It's a really great idea-8-)))))
You guys are gr8
u can write me at

re:Block IP address country/region

Sesso's picture

The impression I got from the OP's question is that it's this
identifying information he's worried about. I interpreted it as "if
they can't use reverse DNS to find out who the IP is assigned to, can
they use WHOIS to find out something more specific than the ISP?"

Geolocation by IP address is misguided

Vince Littler's picture

IP [Internet Protocol] is about providing data transport services, not about providing client data such as geolocation.

I have no reference to hand on the different protocol levels, but I would refer to the OSI 7 layer model of datacommunications as an example.

Geolocation information belongs at a higher level than the IP level, where I do not know, but I tend to think it is a new service at an application level.

It is not for any server to look at the client and guess where it is, it is for the client to report where it thinks it is and it is for the client to engage services to discover where it is from some kind of local geolocation server. And only if the user so chooses.

For example, I might be in Gironde France now and know that I will be in Berlin tomorrow. If I plan to see a film in Berlin, location based services are only useful if I can say I am in Berlin, while I do my planning here in Gironde. I do not want to fight with a 'helpful' service which pushes Gironde info at me when I really want Berlin info


Anonymous's picture

I really agree so much. I work in France with a system in en-us (mostly by default) or en-uk or en-ie (if I can) & get fed up with irrelevant localized US info being thrown at me like the rest of the world doesn't exist!


Jim B's picture

There are several good geolocation products in the market like below.

Also see

Anonymous's picture

geoip's match

Nicolas Bouliane's picture

Hi people,

I'm proud to announce you that you can now
match by country with iptables,

iptables -A INPUT -m geoip --src-cc CA

more at:
You can also read the offical netfilter's thread:

Nicolas Bouliane
cookinglinux TM

All private networks are in America

Anonymous's picture

This is just stupid:

LAT: 33.98
LONG: -118.45
LAST_UPDATED: 16-May-2001
LOOKUP_TYPE: Block Allocation

CAIDA Example

Andrew's picture

This output was meant as an example of the CAIDA NetGeo output. I believe the actual reason for CAIDA pointing to Marina Del Rey was their default for unknown locations (and also how the site would appear internally to CAIDA).

For historical reasons

El Buki's picture

Unroutable ranges like 10.x.y.z are never re-registered, so where ARIN is concerned they still "belong" to IANA, onetime co-ordinator of the entire IP address space. IANA was in Marina del Rey for easy access to UCLA (an original ARPAnet node dating to 1969).

Perl geolocation

Anonymous's picture

CAIDA is old and inaccurate. If you're using Perl you should be using IP::Country (free) or MaxMind (free-ish), both available from CPAN. If you're using java or coldfusion, you should be using javainetlocator. I've written elsewhere about the accuracy of geolocation, and how city-level geolocation is inaccurate.

--Nigel Wetters Gourlay

p.s. SpamAssassin now uses IP::Country, which is flattering ;)

Re: Geolocation by IP Address

Anonymous's picture

I am in Pisa, Italy and your system placed me in Amsterdam, Netherlands.
The reason is simple: you queried but it is not the only Internet Registry. European ip addresses information is stored in You have to query the ripe database too.
I guess the same could apply to other Internet Registries like for the Asia-Pacific region...

Anyway I like your approach. Good luck

Got mine bang on

Anonymous's picture

right down to the correct town, good but also worrying...

Re: Geolocation by IP Address

Anonymous's picture

Erm, Amsterdam/Netherlands is nowhere near Swindon/UK. You must be joking?

Re: Geolocation by IP Address

Anonymous's picture

CAIDA is stupid and out of date. Your IP address is marked in the ARIN (US) database as assigned to RIPE (Europe). It doesn't check where in Europe.

RIPE Network Coordination Centre (RIPE-NCC)
Singel 258
Amsterdam, NH 1016 AB

Use an up-to-date database if you're going to try this - IP::Country or JavaInetLocator. CAIDA was a proof of concept, but no one should be using it now.

CAIDA is world's trash can,

Anonymous's picture

CAIDA is world's trash can, full of every country's garbage! They are extremely silly! They are hybrids monkeys, not human beings. We should evacuate CAIDA.

Re: Geolocation by IP Address

Anonymous's picture

Same for two different locations in Germany (one PPP pooled,
one static IP at a rackhoster).

They must assume that the whole of Europe is off for smoking
weed in Amsterdam ;-)

Re: Geolocation by IP Address

Anonymous's picture

Maybe works well in the USA but not here.

The Internet just doesn't work the same way here in the UK - most broadband connections are through British Telecom's network, even if BT isn't their ISP, or through a very small number of cable companies. Almost all dial-up users connect through the national BT phone network on 'virtual', national numbers. The London INternet Exchange is the main peering point, so usually I expect to be placed in London.

The High Earth Orbit site placed me in Amsterdam (that's in the Netherlands by the way).

Re: Geolocation by IP Address

Anonymous's picture

I'm in Venezuela and the reported IP address is in Uruguay!

Re: Geolocation by IP Address (inaccurate results)

Anonymous's picture

Depending on the intended use, this system will be useful/not useful. In my case (and likely everyone else's) it reports the location of my ISP's point of presence, not the actual location of where the IP is routed. In my case, it's about 25-30 miles off target. Now, granted, it knows the state, and pretty close the locality, so for something keying off of state/general city area, it might be useful. But if you want GPS level accuracy, this simply isn't going to give it to you.

Re: Geolocation by IP Address

Anonymous's picture

My real location in the great state of Tennessee shows up as in the heart of Australia

IP Address in Conflict

oil painting portrait artists's picture

Why am I seeing IP Address in Conflict in my computer? I have my own dsl connection. Is it possible that I have the same IP as someone from somewhere?

Re: Geolocation by IP Address

Anonymous's picture

Well my supposed location was at least still in Europe, 1150 kms due north of the real location. But according to the map on the site it put me on the Greenwich meridan and the equator.

Re: Geolocation by IP Address

nilspace's picture

As discussed in the article, the current utilities will sometimes produce erroneous results. Australia is the 'default' unknown response.

I have put a section below the map on the webpage for you to input your actual location. It is then possible to apply new heuristics for determining location when it is unknown (or incorrect).


Re: Geolocation by IP Address

Anonymous's picture

Manually adding IP addresses to a database will lead to great suffering. How will you ensure that the changes made are accurate in six months' time?

--Nigel Wetters Gourlay

Re: Geolocation by IP Address (doing it in Java)

Anonymous's picture


About a month ago, I wrote a small Java library that uses different Geo Internet services to provide you with location information. It's really basic, but it works for me.


Any comments, patches appreciated.



Anonymous's picture

That was a long time ago & the link has moved. Care to update it?

Re: Geolocation by IP Address (doing it in Java)

Anonymous's picture

You assume that by combining different Geo Internet services you will improve accuracy, which isn't the case. You'd be spending your time in a better way by measuring the accuracy of the various services and using just the most accurate. I'm sure that you'll find this one to be the best.


Geolocation by IP Address sucks

Anonymous's picture

I'm somewhere ... and google tries to make me happy with a language I don't understand (great!)
I'm trying to get an online quote, and the server tells me "this service is only available for our US customers" ... great ! (cyclades; fortunately I've got a proxy somewhere else ;-)
I never liked when computers are trying to predict what I want (i.e. getting too smart, 'cause in 90%, they are plainly wrong)


Anonymous's picture

yep, I know I shouldn't follow-up my own article ... but so-what ...
perhaps some people would prefere postings/comment like:
Anonymous@[Lat: 49.5817

Anonymous's picture

Sob. I'm rather disappointed that my site didn't make it into the 'Resources' section at least ... especially considering it is free, the DB is open and available, and there's an API if you don't want to do the whole DB thing. You can even embed the zoom-in applet in your own page if you want...


Re: Geolocation by IP Address

Anonymous's picture

And this is all still available after everyone freaked out about Sean Gorman? Talk about shooting-the-messenger-based information technology security solutions for the Enterprise.