MaxMind GeoIP is a collection of APIs for looking up the location of an IP address. It includes support for lookup of country, region, city, latitude, and longitude. Free GeoLite databases are available for the country and city.
Installation
First install the software :
aptitude install geoip-bin mkdir /usr/local/share/GeoIP cd /usr/local/share/GeoIP wget http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz gunzip GeoLiteCity.dat.gz ln -s /usr/local/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
To use it :
geoiplookup 84.226.106.171