If you want to know the location of a server connected to the Internet, you need a tiny, useful tool called geoiplookup. In Debian or Ubuntu the installation is quite easy:
sudo aptitude install geoip-bin
After installation you’re able to use geoiplookup from the command line:
user@server:~$ geoiplookup www.heise.de
GeoIP Country Edition: DE, GermanyBut that’ll only show you the country of the server’s location. For more precise information MaxMind‘s LGPL version of their GeoIP database comes in handy. It’s being updated at the beginning of each month and available via this link (approx. 30 MB).
Simply download the archive, gunzip it and move it to the proper location:
gunzip GeoLiteCity.dat.gz mv GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
After that, geoiplookup returns more accurate location details on a city-level:
user@server:~$ geoiplookup www.heise.de GeoIP Country Edition: DE, Germany GeoIP City Edition, Rev 1: DE, 06, Hanover, (null), 52.366699, 9.716700, 0, 0 GeoIP City Edition, Rev 0: DE, 06, Hanover, (null), 52.366699, 9.716700
Tossing longitude and latitude to Google Maps it’ll show the location of the Heise Verlag’s office, although the servers are running in Frankfurt/Main 350 kilometers south of Hannover.
If you want to keep the information up to date you should create a small script, triggered by a cronjob running at 1:30am on the third day of each month.
The cronjob, assuming you define cronjobs via /etc/crontab:
30 1 3 * * root /root/scripts/update_geoip_db.sh
The “script”:
#!/bin/bash wget -t 5 "http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz" gunzip -f /root/scripts/GeoLiteCity.dat.gz mv /root/scripts/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
On the console you usually won’t get more detailed information, because MaxMind doesn’t include all their knowledge in the LGPL version of their GeoIP databases. In case you need additional information you might want to use MaxMind’s freely accessible web-interface which uses some of the purchasable databases as its backend.
But don’t expect to get information on a district, street or even house number level. That’s simply not possible due to the common IP address block allocation and the fact that most of the information is gathered from whois data, which mostly doesn’t include the “end user’s” location rather than the ISP’s office address.
Add your comment below, or trackback from your own site.
Subscribe to these comments.
Be nice. Keep it clean. Stay on topic. No spam.
You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">