Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As all Internet users, I've visited web sites which appear to know in which country and city I'm located. I understand that these web sites typically look up my IP address in a database which maps IP address to country / city which works fairly well. I've also seen companies selling this type of database.

How is this database, which maps an IP address to a country / city, created in the first place?

Is there a central database somewhere where each ISP registers the link between IP address and country/city? Or does the companies selling geolocation databases contact different ISP's and purchase the mapping information from them? Or is there some organization 'above' ISP's who keeps track of this?

share|improve this question

Your ISP gives you your IP address. They own a block of IP addresses that, in one way or another, originate from the IANA.

The business that purchases those IP blocks has a physical location/address that can help place them geographically. (it only helps because, for instance, they can hand out an IP address to someone living in a different geographical area)

On average though, that method generally works.

Additionally, the ISP may have their own DNS servers. When you navigated to that website, your ISP's DNS server helped your browser get there. That DNS server also has a public IP address that is owned and registered.

In the end, I think it often boils down the address of the owner of the IP address as registered with the IANA.

share|improve this answer
I don't think its as easy as that. Lets take an example. The Swedish ISP Comhem has customers in entire Sweden. According to, the IP address I am currently using is owned by Comhem located in Stockholm (the entire range - But I'm located 600KM from Stockholm and if I perform a GEO lookup on my IP address, it will tell me what city I'm in. Just using the owners address would be far to vague to include city properly. – Martin Jul 6 '12 at 20:37
Also, I don't see what the DNS has to do with it. Yes, my PC will use my ISP's DNS server when performing a query. But this only resolves host name to a specific IP address. But that's not linked to geo location at all. Also, a geo lookup server won't know what DNS server I'm using. – Martin Jul 6 '12 at 20:39
@Martin: It's partially related because some authoritative DNS servers (e.g. those which host are configured to return different results depending on the asker's address. Usually they only see the addresses of ISP caching servers, not the user's directly, but that's sufficient to redirect the user to a geographically close web server. – grawity Jul 6 '12 at 20:58
@Martin I take your point with the ISP being remote. However, and to be honest I'm speculating here, I would be surprised if the ISPs didn't distribute sub-blocks based on political geography (cities, etc.). Your linked article states the primary source of data is the registry itself, secondary is the ISP, and beyond that, just data mining and your own various user or account data. I still think the owner of the IP is the source for most of the data. – JoshP Jul 6 '12 at 21:01
up vote 0 down vote accepted

Found some answers on WikiPedia:

There are a number of free and paid subscription geolocation databases, ranging from country level to state or city—including ZIP/post code level—each with varying claims of accuracy (generally higher at the country level). These databases typically contain IP address data which may be used in firewalls, ad servers, routing, mail systems, web sites, and other automated systems where geolocation may be useful. An alternative to hosting and querying a database is to obtain the country code for a given IP address through a DNSBL-style lookup from a remote server.

Some commercial databases have augmented geolocation software with demographic data to enable demographic-type targeting using IP address data.

The primary source for IP address data is the regional Internet registries which allocate and distribute IP addresses amongst organizations located in their respective service regions:

  • African Network Information Centre (AfriNIC)
  • American Registry for Internet Numbers (ARIN)
  • Asia-Pacific Network Information Centre (APNIC)
  • Latin American and Caribbean Internet Address Registry (LACNIC)
  • RIPE Network Coordination Centre (RIPE NCC)

Secondary sources include:

  • Data mining or user-submitted geographic location data. For example, a weather web site might ask visitors for a city name to find their local forecast. Another example would be to pair a user's IP address with the address information in his/her account profile.
  • Data contributed by internet service providers.
  • Merging databases from different suppliers.
  • Guesstimates from adjacent Class C range and/or gleaned from network hops.

Accuracy is improved by:

  • Data scrubbing to filter out or identify anomalies.
  • Statistical analysis of user submitted data.
  • Utilizing third-party tests conducted by reputable organizations.


share|improve this answer
The content of a link might change (or even die completely). Please add information to your answer, eg by quoting the relevant parts of the article. – Baarn Jul 6 '12 at 21:22

Source Wikipedia:

Though the implementation is not specified, W3C Geolocation API is built on extant technologies, and is heavily influenced by Google Gears Geolocation API. Example: Firefox's Geolocation implementation[7] uses Google's network location provider.[8] Google Gears Geolocation works by sending a set of parameters that could give a hint as to where the user's physical location is to a network location provider server, which is by default the one provided by Google ([9] Some of the parameters are lists of sensed mobile cell towers and Wi-Fi networks, all with sensed signal strengths. These parameters are encapsulated into a JavaScript Object Notation (JSON) message and sent to the network location provider via HTTP POST. Based on these parameters, the network location provider can calculate the location. Common uses for this location information include enforcing access controls, localizing and customizing content, analyzing traffic, contextual advertising and preventing identity theft.[10]

share|improve this answer
Well sir, the Geolocation that runs in your browser is the one thats described there. Which answers "how geolocation based.on IP works" cause it works the same.for ip address and wireless devices. – Rhyuk Jul 6 '12 at 20:41
And next time be a little bit more respectful. – Rhyuk Jul 6 '12 at 20:45

You must log in to answer this question.

protected by JakeGould Oct 16 '15 at 1:24

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged .