geoip

Get Version

1.3.2

‘Geographic info for an IP address’

What

GeoIP searches a GeoIP database from http://maxmind.com for a given host or IP address,
and returns information about the country, city and/or ISP for that IP address,
depending on the database version.

Installing

sudo gem install geoip

Locations

http://github.com/cjheath/geoip
http://geoip.rubyforge.org/

Prerequisites

You need one of the free GeoLite country, city or ASN databases, or a subscription database version.
The last known download locations for the GeoLite database versions are
http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
http://geolite.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz

This API requires the database to be decompressed for searching.

Example

require ‘geoip’
c = GeoIP.new(‘GeoIP.dat’).country(‘www.nokia.com’)
=> [“www.nokia.com”, “147.243.3.83”, 69, “FI”, “FIN”, “Finland”, “EU”]
c.country_code3
=> “FIN”
c.to_hash
=> {:country_code3=>"FIN", :country_name=>"Finland", :continent_code=>"EU",
:request=>"www.nokia.com", :country_code=>69, :country_code2=>"FI", :ip=>"147.243.3.83"}

c = GeoIP.new(‘GeoLiteCity.dat’).city(‘github.com’) => [“github.com”, “207.97.227.239”, “US”, “USA”, “United States”, “NA”, “CA”, “San Francisco”, “94110”, 37.7484, -122.4156, 807, 415, “America/Los_Angeles”] >> c.longitude => -122.4156 >> c.timezone => “America/Los_Angeles”
c = GeoIP.new(‘GeoIPASNum.dat’).asn(“www.fsb.ru”) => [“AS8342”, “RTComm.RU Autonomous System”]

Source Repository

The trunk repository is http://github.com/cjheath/geoip

License

I don’t normally use the GPL license, but this one is derived
from Maxmind’s code, so I use the license they use.

This version Copyright © 2005 Clifford Heath
Derived from the C version, Copyright © 2003 MaxMind LLC

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Clifford Heath, 4th August 2013
Theme extended from Paul Battley