Repository avatar
Monitoring
v1.0.0
active

openipdata

org.openipdata/openipdata

Free IP geolocation, ASN and IP risk lookups. No key, CC0 data, rebuilt twice a day.

Documentation

openipdata.org

mcptry

Free IP geolocation data (CC0) and the website openipdata.org.

A Go Hatchet worker runs the data workflows on a VM (Hatchet Cloud keeps the schedules, run history and dashboard). They collect registry data, geofeeds, BGP, traceroutes, router names and measurements into Postgres, build MMDB and SQLite files with mmdbbuilder, score them, and publish them to the GitHub release latest and a private R2 bucket. The website is one Go binary that reads the published files.

The published data files are CC0 (see LICENSE-DATA); the code is MIT (LICENSE).

Modules

Each is its own Go module and builds on its own; the repo root has no Go code.

PathWhat it isDocs
hatchet/openipdata-worker, the Hatchet worker; one folder per workflow, shared code in schema/, publish/, rirstats/, download/, outputs/, ipdata/this file
mmdbbuilder/mmdbbuilder, the CLI that builds, converts, scores and reads the MMDBs; the worker runs it as a binary"Commands" below
site/openipdata-site, the websitesite/README.md
beacon/openipdata-beacon, the DNS resolver beacon of the website VMbeacon/README.md
iplistener/tails the nginx log of web servers into public.visitor_ipsiplistener/README.md
infra/worker VM setup, units, updater; infra/site/ the website VMinfra/README.md
tools/mapdata, whoisdistricts (run by hand), llm-codes-test (scratch)READMEs in each folder

Docs

Workflows

WorkflowSchedule (UTC)Folder
sync-peeringdb03:23hatchet/pdb/
update-asn-domains04:11, 16:11hatchet/domains/
build-asn-data06:03, 18:03hatchet/asn/
sync-geofeeds00:13hatchet/geofeeds/
sync-bgp03:41hatchet/bgp/
build-geo-data07:09, 19:09hatchet/geo/
resolve-ipsevery 30 minuteshatchet/rdns/
learn-rdns-rules05:17hatchet/rdnsrules/
sync-arin-whois:19 and :49 each hourhatchet/arin/
sync-hosting-ping02:26 on the 1st of the monthhatchet/ping/
import-mlab, import-mlab-sitesby handhatchet/mlab/
sync-tor, sync-vpn, sync-ipsum, sync-forum-spam, sync-c2-feeds, sync-threatfox, sync-honeypotshourly to dailyhatchet/tor/ etc.
build-risk-data:33 each hourhatchet/risk/

Each Postgres table has exactly one writer (list in AGENTS.md). What each workflow does, its inputs, outputs and limits: the files in docs/decisions/.

Deploys

  • Worker: a push to master that changes hatchet/ or mmdbbuilder/ is tested and built by GitHub (.github/workflows/worker.yml) into the rolling release worker. A timer on the worker VM installs a new build when no task is running and puts the old one back if the worker does not stay up. Details and rollback: infra/README.md.
  • Website: push a tag site-YYYY-MM-DD on a master commit; .github/workflows/site.yml builds the release site and the website VM installs it blue/green. See site/README.md, "Release" and "Server".
  • Data: the workflows publish the files themselves; the website VM pulls them every 10 minutes.

Test

cd hatchet && go vet ./... && go test -race ./...
cd mmdbbuilder && go vet ./... && go test -race ./...
cd site && go vet ./... && go test -race ./...

M-Lab export

The manual BigQuery steps moved to docs/mlab-export.md: "Hop export" (for import-mlab) and "Reply-time export" (for import-mlab-sites).

Commands

openipdata-worker                      # serve: connect to Hatchet using HATCHET_CLIENT_TOKEN
openipdata-worker run-asn              # run build-asn-data once locally, without Hatchet
openipdata-worker run-asn -skip-publish  # same, without uploading
openipdata-worker run-pdb              # run sync-peeringdb once locally, without Hatchet
openipdata-worker run-domains          # run update-asn-domains once locally, without Hatchet
openipdata-worker run-geofeeds         # run sync-geofeeds once locally, without Hatchet
openipdata-worker run-geofeeds -skip-upload  # same, without uploading the rows
openipdata-worker run-geofeeds -force-upload # same, uploading even after a drop of over 10%
openipdata-worker run-geofeeds -skip-upload -rdap-budget 100 -domain-budget 100  # a quick local test run
openipdata-worker run-bgp              # run sync-bgp once locally, without Hatchet
openipdata-worker run-bgp -skip-upload # same, without uploading the file
openipdata-worker run-bgp -mrt dump.gz # read a local MRT dump, write the file, upload nothing
openipdata-worker run-tor              # run sync-tor once locally, without Hatchet
openipdata-worker run-vpn              # run sync-vpn once locally, without Hatchet
openipdata-worker run-ipsum            # run sync-ipsum once locally, without Hatchet
openipdata-worker run-forum-spam       # run sync-forum-spam once locally; -force accepts a big drop (the source allows 2 downloads a day)
openipdata-worker run-c2-feeds         # run sync-c2-feeds once locally, without Hatchet
openipdata-worker run-threatfox        # run sync-threatfox once locally (needs ABUSE_CH_KEY); -force accepts a big drop
openipdata-worker run-honeypots        # run sync-honeypots once locally (needs HONEYPOT_FEEDS)
openipdata-worker run-risk             # run build-risk-data once locally (builds the risk MMDB, uploads it to private R2)
openipdata-worker run-risk -skip-upload # same, without the upload
openipdata-worker run-mlab             # run import-mlab once locally (newest file of the inbox)
openipdata-worker run-mlab -file export.csv -skip-upload # import a local CSV, write the layer, upload nothing
openipdata-worker run-mlab -sites      # run import-mlab-sites once locally (newest file of the sites inbox)
openipdata-worker run-mlab -sites -file replies.csv -skip-upload # make the site layer from a local CSV, upload nothing
openipdata-worker run-hosting-ping     # run sync-hosting-ping once locally (about an hour; needs GCP_PING_KEY)
openipdata-worker run-arin             # run sync-arin-whois once locally (up to 24 minutes of lookups, then export and upload)
openipdata-worker run-arin -skip-upload # same, without uploading the layer
openipdata-worker run-geo              # run build-geo-data once locally, without Hatchet
openipdata-worker run-geo -skip-publish  # same, without uploading
openipdata-worker run-geo -force-publish # same, publishing even if the scores dropped more than the gate allows
openipdata-worker run-rdns             # run resolve-ips once locally
openipdata-worker run-rdns -force-replace # allow an intentional layer shrink above 10%
openipdata-worker run-rdns-rules       # learn candidate rules once locally
openipdata-worker run-rdns-rules -reject example.net # withdraw the current rule, without learning
openipdata-worker run-rdns-rules -codes [-domains a.net,b.net] [-force] # only the LLM task propose-codes (needs OPENROUTER_API_KEY)
openipdata-worker run-rdns-rules -hoiho # only the task import-hoiho (CAIDA's router-name rules)
openipdata-worker run-rdns-rules -reject-hoiho a.net,b.net # switch off the Hoiho rules of these suffixes and of every name under them
openipdata-worker run-rdns-rules -accept-hoiho a.net,b.net # switch them on again
mmdbbuilder asn -in <asn-ip/as> -out <file.mmdb>
mmdbbuilder geo -out <file.mmdb> [-names <names.tsv>] [-geonames <cities1000.txt> [-geonames-all <allCountries.zip|txt>]] [-same-country <layer,...>] [-within-first <layer,...>] [-first-country <layer,...>] [-asn-main <asn-prefixes.csv.gz>] [-fallback] [-anycast <hosting-rtt.csv.gz>] <layer.csv.gz>...
mmdbbuilder eval -db <ip2geo.mmdb> -rir <10-rir.csv.gz> [-dbip <f>] [-maxmind <f.mmdb>] [-atlas <probes.csv> [-geonames <cities1000.txt>]] [-holdout-db <f> -holdout-truth <rows.csv>]  # scores as JSON
mmdbbuilder lookup -db <file.mmdb>             # look up builtin public resolver IPs, print a summary
mmdbbuilder lookup -db <file.mmdb> -ip 1.1.1.1
mmdbbuilder lookup -db <file.mmdb> -ips ips.txt # one IP per line, plus the builtin IPs
mmdbbuilder lookup -db <ip2geo.mmdb or published City file> -in ips.txt -out cities.tsv  # reads both layouts; ip<TAB>country<TAB>city for each IP of the file that has a city (used by resolve-ips)
mmdbbuilder lookup -db <ip2geo.mmdb> -in ips.txt -out cities.tsv -with-source  # same, with a fourth column: the record's city_source (used by import-mlab); add -countries to also write IPs that have a country but no city (empty city)
mmdbbuilder gaps -db <ip2geo.mmdb or published City file> -out gaps.txt  # reads both layouts; the IPv4 /24s with a country and no city (a city from one of the eleven guesses 80-asn-main, 82-asn-likely, 84-asn-near, 85-asn-half, 85-holder-city, 86-country-main, 87-rtt-network, 87-rtt-country, 88-asn-far, 89-asn-anywhere, 89-country-near, or from 25-bgp, 30-pdb, 35-rdns-wide, 35-speedtest-site, 36-mlab, 36-same-router, 37-whois-arin, 37-whois-text or 39-github-geofeeds counts as none), as runs "<first /24> <count> <country>" (used by resolve-ips sample-names)
mmdbbuilder convert -db <ip2geo.mmdb|ip2asn.mmdb> -out <file.mmdb> [-geonames <cities1000.txt> [-geonames-all <allCountries.zip|txt>]]  # the published layouts: ip2geo -> GeoLite2-City layout (database_type OpenIPData-City: country.iso_code, city.names.en, location, extra city_source), ip2asn -> GeoLite2-ASN layout (OpenIPData-ASN (compat=GeoLite2-ASN)); used by publish
mmdbbuilder stamp -db <ip2geo.mmdb> -meta meta.json -out <stamped.mmdb>  # rewrites only the metadata: description.openipdata = the compact JSON of meta.json (used by evaluate)

Build

The worker looks for mmdbbuilder next to its own binary, so build both into bin/:

cd hatchet && CGO_ENABLED=0 go build -trimpath -o ../bin/openipdata-worker .
cd mmdbbuilder && CGO_ENABLED=0 go build -trimpath -o ../bin/mmdbbuilder .

The run-* commands need PGSQL (run-geofeeds for public.geofeed_urls and its probe-domains task), and run-geofeeds also needs R2 unless -skip-upload is given (so does run-bgp, unless -skip-upload or -mrt); run-pdb also needs PDB_KEY, and run-geo also needs R2. Set OPENIPDATA_DATA_DIR to a local folder when running off the VM.

PTR_RESOLVER (optional, host:port with a loopback IP, e.g. 127.0.0.1:5335) makes the PTR lookups of resolve-ips and import-mlab ask a local recursive resolver (unbound on the VM, see infra/README.md) first and DoH second; empty uses the system resolver. A bad value stops serve, run-rdns and run-mlab at start.

VM setup

See infra/README.md.

No installation packages available.

Remote