I have geoip setup by following these identical steps (http://php.net/manual/en/geoip.setup.php):
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz
sudo mkdir -v /usr/share/GeoIP
sudo mv -v GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
sudo apt-get install php5-geoip
This works brilliantly and has for several years now with IPv4 addresses. I did not, however realize how broken it was with incoming IPv6 devices. For example, it returns Notice: geoip_country_code_by_name(): Host 26xx:8:xx00:cf20:caxx:ff:fexx:35b5 not found
I have been through quite a few things attempting to fudge it into working, including:
- testing for v6 address and using
geoip_open("/usr/share/GeoIP/GeoIPv6.dat", GEOIP_STANDARD);
Apparently geoip_open is not an available function ala php5-geoip
- I have tried using
geoip_country_code_by_name_v6($ip)
This is another function that is not available even though geoip_country_code_by_name($ip)
works great.
- I have tried including the missing functions via the geoip.inc file from https://github.com/maxmind/geoip-api-php/blob/master/src/geoip.inc
No avail so far.
Is there any way I can easily, within my PHP code select which database I want to use so that I can simply test whether it is an IPv4 or IPv6 address and load the appropriate database?