Better Geo-IP Via An ip2nation Patch
update: this post is outdated as I have now switched to the free maxmind geolite database which is much more accurate, especially after some custom patches I have created (and will share eventually when I have time)
I finally have a website that gets alot of international visitors, so I tried out the nifty ip2nation free geo-ip database with some wordpress plugins to display country flags next to visitors comments. Makes it very pretty and facinating to see where everyone is coming from.
However I noticed a bunch of visitors being lumped in “EU” with the new EU flag. The problem is some of these visitors were clearly from the UK and other specific locations, EU was far too general and perhaps insulting to them that they didn’t see their own proper flag.
Upon checking the ip2nation database from 2006 December I found 1946 entries for EU. That’s far too many. Then after alot of googling I found a script that will do WHOIS queries to get more specific country information.
Since I had to spread out the WHOIS calls over 10 seconds apart to be nice to their servers for 2000 enquiries, this takes hours to grab. However there is no reason why I can’t share the patch info with others to help them the same way!
Here the data output from the whois queries, it can be imported directly into ip2nation mysql via phpmyadmin or similar
I did not remove the entries that were not converted from EU, so there is some waste.
There were 1946 EU entries to start, 820 left afterwards.
So a healthy conversion of 1126 entries! Enjoy…