++ed by:
SZABGAB OALDERS IOANR BINJOY PLU

7 PAUSE users
1 non-PAUSE user.

T.J. Mather

NAME

Geo::IP - Look up country by IP Address

SYNOPSIS

  use Geo::IP;

  my $gi = Geo::IP->new();

  # look up IP address '65.15.30.247'
  # returns undef if country is unallocated, or not defined in our database
  my $country = $gi->country_code_by_addr('65.15.30.247');
  $country = $gi->country_code_by_name('yahoo.com');
  # $country is equal to "US"

DESCRIPTION

This module uses a file based 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, 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 a Network that contains the IP address, then returns the country the Network is assigned to.

CLASS METHODS

$gi = Geo::IP->new();

Constructs a new Geo::IP object with the default database located inside your system's datadir, typically /usr/local/share/GeoIP/GeoIP.dat.

$gi = Geo::IP->open( $database_filename );

Constructs a new Geo::IP object with the database located at $database_filename.

OBJECT METHODS

$code = $gi->country_code_by_addr( $ipaddr );

Returns the ISO 3166 country code for an IP address.

$code = $gi->country_code_by_name( $ipname );

Returns the ISO 3166 country code for a hostname.

$name = $gi->country_name_by_addr( $ipaddr );

Returns the full country name for an IP address.

$name = $gi->country_name_by_name( $ipname );

Returns the full country name for a hostname.

VERSION

0.10

AUTHOR

Copyright (c) 2002, T.J. Mather, tjmather@tjmather.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.