Difference between revisions of "geoip"

From thelinuxwiki
Jump to: navigation, search
(Created page with " == installation (gentoo) == # '''emerge -av --quiet dev-libs/geoip''' default data directory /usr/share/GeoIP usage examples: check database versions # geoiplookup -v /...")
 
Line 9: Line 9:
  
 
check database versions
 
check database versions
  # geoiplookup -v /usr/share/GeoIP  
+
  # '''geoiplookup -v /usr/share/GeoIP'''
  
 
lookup country only
 
lookup country only
  # geoiplookup -f /usr/share/GeoIP/GeoIP.dat 31.192.109.7                                             /usr/share/GeoIP
+
  # '''geoiplookup -f /usr/share/GeoIP/GeoIP.dat 31.192.109.7'''
 
  GeoIP Country Edition: RU, Russian Federation
 
  GeoIP Country Edition: RU, Russian Federation
  
 
lookup city only
 
lookup city only
  # geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat 142.11.235.1
+
  # '''geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat 142.11.235.1'''
 
  GeoIP City Edition, Rev 1: US, OK, Oklahoma, Tulsa, 74103, 36.155399, -95.993896, 671, 918
 
  GeoIP City Edition, Rev 1: US, OK, Oklahoma, Tulsa, 74103, 36.155399, -95.993896, 671, 918
  
 
lookup ASN only
 
lookup ASN only
  # geoiplookup -f /usr/share/GeoIP/GeoIPASNum.dat 216.77.188.73                                       /usr/share/GeoIP
+
  # '''geoiplookup -f /usr/share/GeoIP/GeoIPASNum.dat 216.77.188.73'''
 
  GeoIP ASNum Edition: AS6389 BellSouth.net Inc.
 
  GeoIP ASNum Edition: AS6389 BellSouth.net Inc.
  

Revision as of 20:09, 21 July 2013

installation (gentoo)

# emerge -av --quiet dev-libs/geoip

default data directory

/usr/share/GeoIP

usage examples:

check database versions

# geoiplookup -v /usr/share/GeoIP 

lookup country only

# geoiplookup -f /usr/share/GeoIP/GeoIP.dat 31.192.109.7
GeoIP Country Edition: RU, Russian Federation

lookup city only

# geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat 142.11.235.1
GeoIP City Edition, Rev 1: US, OK, Oklahoma, Tulsa, 74103, 36.155399, -95.993896, 671, 918

lookup ASN only

# geoiplookup -f /usr/share/GeoIP/GeoIPASNum.dat 216.77.188.73
GeoIP ASNum Edition: AS6389 BellSouth.net Inc.


cron script to update the free databases

#!/bin/bash
curl http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz | gzip -d > /usr/share/GeoIP/GeoIP.dat
curl http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz | gzip -d > /usr/share/GeoIP/GeoLiteCity.dat
curl http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz | gzip -d > /usr/share/GeoIP/GeoIPASNum.dat