Geo::IP - Look up country by IP Address
use Geo::IP; my $gi = Geo::IP->new('/usr/local/geoip/Geo-IP.db'); # look up IP address '184.108.40.206' # returns undef if country is unallocated, or not defined in our database my $country = $gi->lookup_country('220.127.116.11'); $country = $gi->lookup_country_by_name('yahoo.com'); # $country is equal to "US"
This module uses the Berkeley database. This database simply contains IP blocks as keys, and countries as values. The data is obtained from the ARIN, RIPE, and APNIC whois servers. This database should be more complete and accurate than reverse DNS lookups.
This module can be used to automatically select the geographically closest mirror, or to target advertising by country, to analyze your web server logs to determine the countries of your visiters, for credit card fraud detection, and for software export controls.
To find a country for an IP address, this module finds Networks that contain the IP address, starting with a netmask of 32, going up to 3 until it finds a matching IP Block.
IP to country database up-to-date as of February 1st, 2002 Updates to the database will be available on the first week of each month.
Copyright (c) 2002, T.J. Mather, email@example.com, New York, NY, USA
All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.