2

Can anyone please let me know what's the best way of using the GeoIP databases in order to detect the country of visitors by IP.

I used to have a table populated with IPv4 information ( longstart, longend, country code ) and with an INET_ATON() instruction I would get the relevant country code.

However, we would now want to use the IPv6 database and grab country code for IPv6 IPs as well. But not sure what's the best way to use these databases. I can see they offer various databases now(geolite legacy, or geolite 2, or the APIs), they also offer some update script - not sure how this works though, or in relation with what.

Any help would be appreciated. Thank you.

Lia
  • 31
  • 4
  • That depends on you and your needs. I'm using the binary database embedded in an Apache module, which automatically associates every incoming request with a location. It's great. Whether this is your required use case nobody can tell you. – deceze May 08 '15 at 14:23

1 Answers1

0

Have you tried using http://php.net/manual/en/intro.geoip.php

You can also use Maxmind's downloadable GeoIP Database here http://dev.maxmind.com/geoip/geoip2/geolite2/

OmniPotens
  • 1,125
  • 13
  • 30
  • Thanks for your answer - it seems like a good solution. They update their databases each month (as stated in http://dev.maxmind.com/geoip/legacy/geolite/). Any idea if this extension is somehow updated? Sorry if it's a dumb question - not very familiar with server things. – Lia May 08 '15 at 16:36
  • You just need to keep a weekly reminder so you have your eyes on their website to check for updates on anything. – OmniPotens May 08 '15 at 16:37
  • Thanks for your answer. I ended up using the API here https://github.com/maxmind/GeoIP2-php, with a cron that will keep the database updated. Thanks again! – Lia May 08 '15 at 18:27
  • @OmniPotens Do you know if there is a free geo db more accurante than the free geolite.dat provided by MaxMind ? – zeflex May 16 '15 at 03:24
  • @zeflex Give me some time to check around then get back to you on it – OmniPotens May 18 '15 at 13:40
  • @zeflex Couldn't get any better than this. If at the course of work I stumble on a better solution then I'll get it to you here. – OmniPotens May 20 '15 at 11:56
  • @OmniPotens Ok no problem, thanks for the investigation. – zeflex May 20 '15 at 16:52