root/scripts# time perl geoip_ -use_geoip2_readerĭoing geoip lookup for 325125 number of ips, with GeoIP2::Database::Reader module. Try with: -use_maxmind_reader_xs or -use_maxmind_reader or -use_geoip2_reader ") Īnd some usage examples: /root/scripts# time perl geoip_ -use_maxmind_reader_xsĭoing geoip lookup for 325125 number of ips, with MaxMind::DB::Reader::XS module. My $reader_country = GeoIP2::Database::Reader->new( file => '/usr/share/GeoIP/GeoIP2-Country.mmdb') įoreach $data = $reader_country->country( ip => $_) ĭie("Invalid option provided. however, modgeoip is pointing to GeoIP.dat which is not updated. " number of ips, with GeoIP2::Database::Reader module. after installing, i get these 3 files grabbed from maxmind:-rw-r-r- 1 root root 7451457 Sep 9 01:52 GeoLite2-ASN.mmdb-rw-r-r- 1 root root 74436010 Sep 9 01:52 GeoLite2-City.mmdb-rw-r-r- 1 root root 6312408 Sep 9 01:52 GeoLite2-Country.mmdb. My $reader_country = MaxMind::DB::Reader->new( file => '/usr/share/GeoIP/GeoIP2-Country.mmdb' ) įoreach $data = $reader_country->record_for_address($_) " number of ips, with MaxMind::DB::Reader module. This is a test perl script to test the performance of all the three modules, with some randomly generated ips: #!/usr/bin/perl
The GeoIP2 City database is a more accurate version of our free GeoLite2 City database. Keep in mind that GeoIP2::Database::Reader is the worst performer, working almost 5x times slower than MaxMind::DB::Reader::XS for querying the country database. To access our most accurate IP geolocation data, use GeoIP2 Precision: City or Insights, which accurately geolocate 4 more IPs to cities and 9 more IPs to postal codes in the United States than the GeoIP2 City database. You can choose from the following modules, which support GeoIP2: Refer to MaxMinds Automatic Updates page for more details.
#MAXMIND MMDB INSTALL#
To help stay up to date with the latest databases, you may want to install the GeoIP Update program provided by MaxMind. Print Dumper $geoip_country->record_for_address('1.1.1.1') Download the databases in binary (mmdb) format, rather than CSV format. My $geoip_country = MaxMind::DB::Reader::XS->new( file => '/usr/share/GeoIP/GeoIP2-Country.mmdb' ) The FASTEST way to use the database is by installing and utilizing the “MaxMind::DB::Reader::XS” perl module.Īnd here is a tiny example: use MaxMind::DB::Reader::XS This article is the result of my struggles to properly use GeoIP v2 database within Perl.