Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reliable city level Geo-IP, free local database

I want to put together a PHP script to resolve city name (nothing else is needed) with a good resolution just for a single country (IRAN). As I have to query the DB for multiple times, its better to go through a downloadable local version. I have read most of posts on stackoverflow and since now I have tested these:

  • GeoIP City from maxmind sounds good, but is not free.
  • GeoIP from maxmind, has a low level of accuracy (about 50-60%)
  • ip2country.net has an IP-2-City Database but not free and does not resolve city names for Iran.
  • I also tried the DB#.Lite from ipinfodb.com which has an API here without any success. The problem is that, it does not detect many city names.
  • I also tried hostip.info API, but it seems to be too slow.
  • There is a free php class with local DB which resolves only the country name.
  • I dont know if there is chance, using Piwik with this GeoIP plugin. It would be appreciated to have ideas if someone knows about it.
  • ipinfo.io is another service which does not resolve city names with accuracy.
  • I dont know if there is a way to use Google analytics to resolve city names, as I think google would be better than any other service regarding countries like Iran.

Any good idea would be really appreciated.

like image 425
Pmpr.ir Avatar asked Aug 04 '13 09:08

Pmpr.ir


1 Answers

This is a tough one and hard to do reliably. I have given it a go in the past and it went something like this

  • Obtain a database of IP addresses, plus cities and countries (http://lite.ip2location.com/database-ip-country-region-city OR http://ipinfodb.com/ip_database.php)
  • Get the IP address and query for it against those tables to find the city and country
  • Finally check if its in Iran using the country column

There are paid for services that can do this really quickly for you. It might take you ages to get something working that is still unreliable because you simply do not have the data. I would seriously consider http://www.maxmind.com/en/city_per - unless of course this is a completely none commercial project and $ is a no no.

If you can get the lat and long from an IP table, even without the city data then you may want to then use something like this to check for the nearest city of Javascript is an optio n - Finding nearest listed (array?) city from known location.

What about the browsers Share Location feature?

like image 186
Jake N Avatar answered Oct 20 '22 12:10

Jake N