blob: 9e09c9809e98951bc46731c7a859e437aff1b528 [file] [log] [blame]
GeoIP 1.4.0
IMPORTANT API Change for 1.3.x and above users for GeoIP Region database
GeoIPRegion.region is no longer a pointer but an in-structure
array so test the first byte of region == 0 rather testing if the region
pointer is NULL.
IMPORTANT API Change for 1.1.x and above users - as of GeoIP 1.1.0 the
GeoIP_country_xxx_by_xxx functions return NULL if a country can not
be found (it used to return '--' or 'N/A'. Be sure to check the
return value for NULL, to avoid segmentation faults!
GeoIP is a C library that enables the user to find geographical and
network information of an IP address.
Included is a free GeoLite Country database
that is updated at the beginning of every month.
To download the latest free GeoLite Country database, go to:
There is also a free city-level geolocation database, GeoLite City,
available from:
We also offer commercial GeoIP databases with greater accuracy and
additional network information, for more details, see:
As of version 1.3.6, the GeoIP C library is thread safe.
This module can be used to automatically select the geographically closest
mirror, to analyze your web server logs to determine the countries of your
visitors, for credit card fraud detection, and for software export controls.
If you use GeoIP to block access from high risk countries in order
to reduce fraud or abuse, you should also block access from known
proxy servers. For more details, see:
To install, run:
make check
make install
The GeoIP C library relies on GNU make, not on BSD make
There are four options available:
GEOIP_STANDARD - read database from filesystem, uses least memory.
GEOIP_MEMORY_CACHE - load database into memory, faster performance
but uses more memory
GEOIP_CHECK_CACHE - check for updated database. If database has been updated,
reload filehandle and/or memory cache.
GEOIP_INDEX_CACHE - just cache
the most frequently accessed index portion of the database, resulting
in faster lookups than GEOIP_STANDARD, but less memory usage than
GEOIP_MEMORY_CACHE - useful for larger databases such as
GeoIP Organization and GeoIP City. Note, for GeoIP Country, Region
and Netspeed databases, GEOIP_INDEX_CACHE is equivalent to GEOIP_MEMORY_CACHE
The options can be combined using bit operators. For example you can
For examples of how to use the API. The test-geoip.c works with both the free and paid
GeoIP Country databases. The other example programs require the paid databases available
MaxMind offers a service where you can have your database updated
automically each week. For more details see:
Note that it is recommended that you use GNU make. Also, if you are using
OpenBSD, GeoIP requires OpenBSD 3.1 or greater.
if you get "cannot load shared object file: No such file or directory"
error, add the directory was installed to to /etc/
and run ldconfig
On Solaris, if you get a
ld: fatal: relocations remain against allocatable but non-writable sections
error, try running
# make clean
# ./configure --disable-shared
# make
If you get a "ar : command not found" error, make sure that ar is
in your path. On Solaris, ar is typically found in /usr/ccs/bin
If you get a "geoipupdate.c:24: getopt.h: No such file or directory"
error, run
# export CPPFLAGS="-I/usr/local/include"
(assuming that getopt.h is in /usr/local/include)
If you get a "zlib.h: No such file or directory" error, make sure
that the zlib development libraries are installed on your server.
These are typically included in a "zlib-devel" package.
If you get a "bad interpreter: No such file or directory" error
when running ./configure, make sure that there are no DOS
returns in the configure script. To remove DOS returns,
run perl -pi -e 's!\r!!g' configure.
Please contact with any questions or bug