Geo::IP - Look up country by IP Address |
Geo::IP - Look up country by IP Address
use Geo::IP;
my $gi = Geo::IP->new(GEOIP_STANDARD);
# look up IP address '24.24.24.24' # returns undef if country is unallocated, or not defined in our database my $country = $gi->country_code_by_addr('24.24.24.24'); $country = $gi->country_code_by_name('yahoo.com'); # $country is equal to "US"
This module uses a file based database. This database simply contains IP blocks as keys, and countries as values. This database should be more complete and accurate than reverse DNS lookups.
This module can be used to automatically select the geographically closest mirror, to analyze your web server logs to determine the countries of your visiters, for credit card fraud detection, and for software export controls.
Free monthly updates to the database are available from
http://www.maxmind.com/download/geoip/database/
This free database is similar to the database contained in IP::Country, as well as many paid databases. It uses ARIN, RIPE, APNIC, and LACNIC whois to obtain the IP->Country mappings.
If you require greater accuracy, MaxMind offers a database on a paid subscription basis. Also included with this is a service that updates your database automatically each month, by running a program called geoipupdate included with the C API from a cronjob. For more details on the differences between the free and paid databases, see: http://www.maxmind.com/app/geoip_country
Flags can be set to either GEOIP_STANDARD, or for faster performance (at a cost of using more memory), GEOIP_MEMORY_CACHE. When using memory cache you can force a reload if the file is updated by setting GEOIP_CHECK_CACHE.
$database_filename
.
$gi = Geo::IP->open_type( GEOIP_CITY_EDITION_REV1 , GEOIP_STANDARD );
opens the database file in the standard location for GeoIP City, typically /usr/local/share/GeoIP/GeoIPCity.dat.
Are available from SourceForge, see http://sourceforge.net/projects/geoip/
1.27
Geo::IP::Record
Copyright (c) 2005, MaxMind LLC
All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Geo::IP - Look up country by IP Address |