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:

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:

Data Files

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:

geoip = require "geoip" g = geoip.open_type("city", "country") r = g:lookup("") print(r) print( for n, v in r do print(n, v) end