#!/usr/bin/perl use GeoIP2::Database::Reader; if ( $ARGV[0] eq '-h' || $ARGV[0] eq '-help' || $ARGV[0] eq '' ) { help(); exit; } my $reader = GeoIP2::Database::Reader->new( file => '/usr/share/GeoIP/GeoLite2-Country.mmdb', locales => [ 'en', 'de', ] ); my $country = $reader->country( ip => $ARGV[0] ); my $country_rec = $country->country(); print "Country ", $country_rec->iso_code(), "\n"; sub help { print "Usage: ./geoipcountry.pl 1.2.3.4\n"; }