Closed FGIKCM closed 6 years ago
Ah, as I understand, I must not use Geo::IP anymore, but GeoIP2::Database::Reader. This is not documented anywhere that the first library is deprecated...
For those having the same problem than me, here is the new method:
#!/usr/bin/perl -w
use strict;
use GeoIP2::Database::Reader;
use Socket;
my $reader = GeoIP2::Database::Reader->new(file => '/usr/local/share/GeoIP/GeoIP2-Country.mmdb');
# All Reader methods are for IPs. If you have domain name, you will have to get an IP:
my $domain = "xxx.com";
my $ip = inet_ntoa(inet_aton($domain)); # Get the first IP
# Then we extract the country
my $country = $reader->country(ip => $ip);
my $iso2 = $country->country()->iso_code();
Hello,
the
geoipupdate
script only generate .mmdb files. But using the MaxMind perl module Geo::IP, this format does not seems to be recognized (the API looks for .dat file).Am I missing something, or is it a bug?
When I perform a
geoipupdate
into an empty data directory, with a valid subscription:$ geoipupdate -v -f /etc/GeoIP.conf -d /usr/local/share/GeoIP/
I get:
$ ls -Al /usr/local/share/GeoIP/
If I want to force using the .mmdb file instead of .dat in Perl:
$ cat test.pl
I get:
$ perl test.pl