Difference between revisions of "geoip"

From thelinuxwiki
Jump to: navigation, search
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
 +
 +
 +
== Package info==
 +
 +
      Homepage:      http://dev.maxmind.com/geoip/legacy/downloadable
 +
      Description:  easily lookup countries by IP addresses, even when Reverse DNS entries don't exist
 +
      License:      LGPL-2.1 GPL-2 MaxMind2
 +
 +
<p>geoip offers free versions of their databases which are claimed to be 99.5% accurate.  They are updated once per month on the 2nd.
 +
</p>
  
 
== installation (gentoo) ==
 
== installation (gentoo) ==
Line 6: Line 16:
 
  /usr/share/GeoIP
 
  /usr/share/GeoIP
  
usage examples:
+
 
 +
== usage examples ==
  
 
check database versions
 
check database versions
Line 24: Line 35:
  
  
== cron script to update the free databases ==
+
== update the free databases ==
+
  # geoipupdate.sh -f
  #!/bin/bash
+
  Updating GeoIP databases...
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
+
  
 
[[category:geolocation]]
 
[[category:geolocation]]

Latest revision as of 20:18, 23 June 2016


Contents

Package info

     Homepage:      http://dev.maxmind.com/geoip/legacy/downloadable
     Description:   easily lookup countries by IP addresses, even when Reverse DNS entries don't exist
     License:       LGPL-2.1 GPL-2 MaxMind2

geoip offers free versions of their databases which are claimed to be 99.5% accurate. They are updated once per month on the 2nd.

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.


update the free databases

# geoipupdate.sh -f
Updating GeoIP databases...