gogeoip2
gogeoip2 is a Go-based IP lookup tool which provides geographic metadata for an IPv4 address in it's simplest form. It can also be extended (with a premium database) to provide ISP information (i.e. ASN and ISP name)
This data allows one to make informed decisions about who owns IP addresses/network blocks. This tool was used at HotelTonight to make decisions about automatically blocking traffic using a scoring algorithm based on network reputation.
A demo service is currently hosted (and rate-limitted) at http://geo.srv.im — hosted on Docker by Hyper!
Example Output
~ % curl -s "http://geo.srv.im/ip/173.247.196.18?lat=35.0&lng=-120.0" | jq .
{
"ip": "173.247.196.18",
"asnum": 19165,
"city": "San Francisco",
"country": "United States",
"country-iso": "US",
"continent": "NA",
"lat": 37.7758,
"lng": -122.4128,
"time-zone": "America/Los_Angeles",
"distance": 376.6809639080358,
"hostnames": [
"x.196.247.173.web-pass.com."
],
"asorg": "Webpass Inc.",
"isp": "Webpass",
"org": "Webpass",
"cidr-report": "http://www.cidr-report.org/cgi-bin/as-report?as=AS19165&view=2.0",
"cleantalk-report": "https://cleantalk.org/blacklists/AS19165",
"ipinfo-report": "http://ipinfo.io/AS19165",
"peering-db-report": "https://beta.peeringdb.com/api/asn/19165"
}
Running Locally
- Download the MaxMind GeoLite2 City database and place it in the root directory.
- (optional) Purchase and download the GeoIP2 ISP database and put it in the root directory.
- Grab the build dependencies using
go get -v ./...
from the root directory.
- Build the package using
go build
- Run the server using
./gogeoip2 server
Legal Notices
This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com.