Skip to content

Commit cb30419

Browse files
authored
Merge pull request #41 from zmap/phillip/geolite2-data-access
MaxMind GeoLite/GeoIP README Improvements
2 parents 12e3016 + 5336d01 commit cb30419

4 files changed

Lines changed: 32 additions & 12 deletions

File tree

220 KB
Loading

README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,39 @@ zannotate --help
4242
4343
Below are instructions for getting datasets from the below providers.
4444

45-
### GeoLite2-ASN
45+
### MaxMind GeoIP ASN and City (Formerly GeoIP2)
46+
47+
MaxMind provides datasets for IP geolocation and ASN data in both a free (GeoLite) and paid (GeoIP) version.
48+
Additionally, both the GeoLite and GeoIP datasets come in two access patterns - a downloadable database file that can be queried locally and a web API.
49+
The GeoIP module in ZAnnotate supports the local database in both GeoLite and GeoIP versions.
50+
51+
The following assumes you want to use the free GeoLite datasets, but the process is similar for the paid GeoIP data.
52+
4653
1. [Sign-up form](https://www.maxmind.com/en/geolite2/signup) for MaxMind GeoLite Access
4754
2. Login to your account
48-
3. Go to the "GeoIP / GeoLite" > "Download files" section where you should see a list of available databases
49-
4. Download the `.mmdb` files for GeoLite ASN
50-
5. Unzip the downloaded file and test with:
55+
3. Go to the "GeoIP / GeoLite" > "Download files" section and download the zip files for either GeoLite ASN or GeoLite City
56+
datasets.
5157

58+
![GeoLite Download Page](.github/readme-images/maxmind-geolite-downloads-screenshot.png)
59+
60+
4. Unzip, place the `.mmdb` files somewhere and test with the below.
61+
62+
#### MaxMind GeoIP City
5263
```shell
53-
echo "1.1.1.1" | zannotate --geoasn --geoasn-database=/path-to-downloaded-file/GeoLite2-ASN_20250923/GeoLite2-ASN.mmdb
64+
echo "171.67.71.209" | ./zannotate --geoip2 --geoip2-database=./path-to-geolite2.mmdb
5465
```
5566

67+
```json
68+
{"ip":"171.67.71.209","geoip2":{"city":{"name":"Vallejo","id":5405380},"country":{"name":"United States","code":"US","id":6252001},"continent":{"name":"North America","code":"NA","id":6255149},"postal":{"code":"94590"},"latlong":{"accuracy_radius":50,"latitude":38.1043,"longitude":-122.2442,"metro_code":807,"time_zone":"America/Los_Angeles"},"represented_country":{},"registered_country":{"name":"United States","code":"US","id":6252001},"metadata":{}}}
69+
```
70+
71+
#### MaxMind GeoLite ASN
5672
```shell
57-
{"ip":"1.1.1.1","geoasn":{"asn":13335,"org":"CLOUDFLARENET"}}
73+
echo "171.67.71.209" | ./zannotate --geoasn --geoasn-database=/path-to-asn-file.mmdb
74+
```
75+
76+
```json
77+
{"ip":"171.67.71.209","geoasn":{"asn":32,"org":"STANFORD"}}
5878
```
5979

6080
### BGP Routing Tables

geoip2.go renamed to geoip.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ type GeoIP2Annotator struct {
9393

9494
// GeoIP2 Annotator Factory (Global)
9595
func (a *GeoIP2AnnotatorFactory) AddFlags(flags *flag.FlagSet) {
96-
flags.BoolVar(&a.Enabled, "geoip2", false, "annotate with Maxmind GeoIP2 data")
96+
flags.BoolVar(&a.Enabled, "geoip2", false, "annotate with Maxmind GeoIP2/GeoLite data")
9797
flags.StringVar(&a.Path, "geoip2-database", "",
98-
"path to MaxMind GeoIP2 database")
98+
"path to MaxMind GeoIP2/GeoLite database")
9999
flags.StringVar(&a.Mode, "geoip2-mode", "mmap",
100-
"how to open database: mmap or memory")
100+
"how to open database: 'mmap' or 'memory'")
101101
flags.StringVar(&a.Language, "geoip2-language", "en",
102102
"what language geoip2 database is in")
103103
flags.StringVar(&a.RawInclude, "geoip2-fields", "*",

geoipasn.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ type GeoIPASNAnnotator struct {
4242
}
4343

4444
func (fact *GeoIPASNAnnotatorFactory) AddFlags(flags *flag.FlagSet) {
45-
flags.BoolVar(&fact.Enabled, "geoasn", false, "annotate with Maxmind Geolite ASN data")
45+
flags.BoolVar(&fact.Enabled, "geoasn", false, "annotate with Maxmind GeoLite/GeoIP ASN data")
4646
flags.StringVar(&fact.Path, "geoasn-database", "", "path to Maxmind ASN database")
47-
flags.StringVar(&fact.Mode, "geoasn-mode", "mmap", "how to open database: mmap or memory")
47+
flags.StringVar(&fact.Mode, "geoasn-mode", "mmap", "how to open database: 'mmap' or 'memory'")
4848
flags.IntVar(&fact.Threads, "geoasn-threads", 5, "how many geoASN processing threads to use")
4949
}
5050

@@ -63,7 +63,7 @@ func (fact *GeoIPASNAnnotatorFactory) MakeAnnotator(i int) Annotator {
6363
return &v
6464
}
6565

66-
func (fact *GeoIPASNAnnotatorFactory) Initialize(conf *GlobalConf) error {
66+
func (fact *GeoIPASNAnnotatorFactory) Initialize(_ *GlobalConf) error {
6767
if fact.Path == "" {
6868
log.Fatal("no GeoIP ASN database provided")
6969
}

0 commit comments

Comments
 (0)