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?


4 Answers 4


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:


The files contain records that look like this:


which corresponds to:


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.

  • The member mirrors on arin appear to be out of date. The latest data can be found directly on each member's server. For example, ftp.afrinic.net/stats/afrinic/delegated-afrinic-latest
    – James
    Commented Apr 28, 2015 at 0:27
  • @Nick Is there some way I can +1000 your answer? Commented Jan 3, 2016 at 22:57
  • @AmyNeville Glad it was helpful, Amy!
    – Nick
    Commented Jan 4, 2016 at 7:36

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.

  • NirSoft is a great site, I use several of his tools (IPNetInfo, WhoisThisDomain, DNSDataView, etc.)
    – MrWhite
    Commented Sep 18, 2012 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
    Commented Sep 18, 2012 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 :)
    – user6901
    Commented Sep 18, 2012 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
    Commented Sep 19, 2012 at 14:56
  • @Nick no problem :)
    – user6901
    Commented Sep 19, 2012 at 22:58

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.

  • 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
    Commented Sep 18, 2012 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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