geoip

command module
v0.0.0-...-ca2ecb2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2020 License: MIT Imports: 7 Imported by: 0

README

geoip

Simple command line utility to parse a local MaxMind GeoIP2 mmdb (leveraging the great oschwald/geoip2-golang library, and use it to enrich a CSV containing an IP address. It currently adds columns for city, country, isAnonymousIP, and isSatelliteProvider.

It's intentionally designed as a typical *nix cli tool, reading from stdin and writing to stdout.

Installing

Installing currently requires Go to be installed

go get github.com/sbogacz/geoip

Example

echo "8.8.8.8" | geoip                                                                                        
8.8.8.8,,United States,false,false

By default it expects the first column to contain the IP address, but that behavior is configurable with the -i flag.

echo "default,dnsserver,8.8.8.8" | geoip -i 2
default,dnsserver,8.8.8.8,,United States,false,false

If the address is quoted in some way, the quoting character can be specified with -c

echo 'default,dnsserver,"8.8.8.8"' | geoip -i 2 -c '"' 
default,dnsserver,"8.8.8.8",,United States,false,false

Getting the GeoIP2 Database on Mac OS

  1. Sign up for the free GeoLite2 DB access
  2. Once you have an account, configure a license key for the new database format
  3. Once generated, either download the generated .conf file, or copy the license key and your account ID to a separate file
  4. (Mac OS) brew install geoipupdate
  5. (Optional) Configure geoipupdate by either copying the generated .conf file above to its default location (can be obtained with -h) or editing the existing file with the copied values from step 3.
  6. Run geoipupdate

Et voila!

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL