Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

How would I go about compiling an accurate database of IP addresses and their related countries to make available as an open source download for any web developer who wants to perform a geographic IP lookup?

It seems that a company called MaxMind has a monopoly on geographic IP data, because most online tutorials I've seen for country lookups based on IP addresses start by suggesting a subscription to MaxMind's paid service (or their less accurate free 'Lite' version, which requires a linkback and is updated once a month).

I'm not completely averse to paying for their solution or using the free one, but the concept of an accurate open source equivalent that anyone can use without restriction appeals to me, and I think it would be useful for the web development community.

How is geographic IP data collected, and how realistic is it to hope to maintain an up-to-date open version?

share|improve this question
    
For interest: Europe hits old internet address limits –  w3d Sep 18 '12 at 1:00

4 Answers 4

Looking at the wikipedia page on IP Addresses:

The Internet Assigned Numbers Authority (IANA) manages the IP address space allocations globally and delegates five regional Internet registries (RIRs) to allocate IP address blocks to local Internet registries (Internet service providers) and other entities.

I'm no expert, but what I think that means is that IP addresses are grouped into "blocks", which are then assigned to different countries and other organisations. From there, I bet you could find a way to identify which block an IP address is part of, and then use that information to determine what country that IP address if from.

I also found a site called Nirsoft that claims to have a list of some of the blocks given to different countries. In addition, the faq of the alternate database that j0nes posted also mentions blocks:

The IP numbers listed in the database are ranges not single numbers. Each line in the database represents a range of IPs numbers (known as a block) representing many hundreds, thousands or even hundreds of thousand IP numbers. [emphasis added]

So my guess is that you will have to identify which blocks belong to different locations, and then make a database of all those blocks, to create your own open source version of the database.

share|improve this answer
    
NirSoft is a great site, I use several of his tools (IPNetInfo, WhoisThisDomain, DNSDataView, etc.) –  w3d Sep 18 '12 at 0:59
    
Thanks for pointing to the five Internet registries. I've written to them to see how to obtain an up-to-date database. I have a feeling it won't be that simple, but we'll see! The Nirsoft IP list was last updated in 2009; I suspect it's no longer reliable. –  Nick Sep 18 '12 at 7:11
    
@Nick since you accepted this answer, would it be possible for you to make your answer an edit to mine? That way people wouldn't read one incomplete answer (because they didn't scroll down, etc.). Also, this is a very interesting question: thanks for posting this on the site :) –  Christofian Sep 18 '12 at 20:22
    
@Christofian Thought it made more sense to mark my answer as correct and edit it to credit your answer as the source that led me to the solution. Hope that's OK! –  Nick Sep 19 '12 at 14:56
    
@Nick no problem :) –  Christofian Sep 19 '12 at 22:58
up vote 4 down vote accepted

After reading Christofian's answer, I did some research and found out that the five Regional Internet Registry members (APNIC, AFRINIC, ARIN, RIPE, and LACNIC) each maintain a copy of the allocated IP address ranges and the associated countries on their public FTP servers. This information is updated daily and mirrored between the five servers.

For example, to access the latest version of the IP address ranges and countries for the five regions as stored by the ARIN FTP server, you'd use these URLs:

ftp://ftp.arin.net/pub/stats/ripencc/delegated-ripencc-latest
ftp://ftp.arin.net/pub/stats/lacnic/delegated-lacnic-latest
ftp://ftp.arin.net/pub/stats/arin/delegated-arin-latest
ftp://ftp.arin.net/pub/stats/apnic/delegated-apnic-latest
ftp://ftp.arin.net/pub/stats/afrinic/delegated-afrinic-latest

The files contain records that look like this:

ripencc|GB|ipv4|195.242.236.0|1024|20040916|assigned

which corresponds to:

registry|cc|type|start|value|date|status

This is the Regional Internet Registry (RIR) Statistics Exchange Format standard, apparently, which is explained on APNIC's site here.

This should provide enough basic information to those interested to compile their own up-to-date databases programatically.

share|improve this answer

There is a free version of a GeoIP database available from Software77. In their FAQ page they say:

We cannot add or remove IPs from the database. The process we use is automated and the IPs in the database are as as we get them from the various registries around the world. If a registry does not list an IP the only way to get it in our database is for the registry to add it to their database.

They also release some updates, and at least for my usage the data was always correct.

share|improve this answer
    
Thank you for this. It seems be up-to-date according to their changelog. I've posted a separate answer with my discoveries about how to obtain this data for those interested in creating their own databases independently. –  Nick Sep 18 '12 at 12:43

I compiled a small SQLite database from the data found over at (Oct 2011): http://www.maxmind.com/app/geolite

4.9MB 7zip file of the database can be downloaded from: http://db.tt/OSXRYfU0

Looks like pulling from the ARIN data like Nick suggested might be a better long-term solution.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.