This is a Lua binding of libGeoIP as published by MaxMind, which looks up IP addresses or host names in a database, which contains some kind of location. This may be the country (in the simplest case), or more detailed information like the city.
This package is available at various locations:
- The most current source is in CVS and can be checked out like this:
cvs -d :pserver:firstname.lastname@example.org:/cvsroot/geoip checkout geoip. Then chdir to this directory and type
- Download a release from the LuaForge files section,
unpack the tar.gz file and also type
- Use the Rock provided, either as binary or as source, like this:
luarocks --from=http://geoip.luaforge.net/rocks install geoip. This is probably the least current version to be available.
In any case, you need to have the library libGeoIP installed. It may already be present on your Unix installation. Otherwise, you have the following options:
- Download the source from MaxMind, compile and install it.
- For Debian, do this:
apt-get install libgeoip1, or if you want to build this module from source, get
- Other distributions may have different package names; if you find out how to do it, please drop me a note so I can add this here.
To function libGeoIP needs data files, which probably are in /usr/share/GeoIP. The default, free datafile has only country information; for more detail, you can download the latest data file "GeoLiteCity.dat" from MaxMind at no cost. For commercial applications you should purchase a license.
A simple Lua script to exercise this library is included. Here it is: