Sign inSign up

letstool/http2prefix

By letstool

Updated 4 months ago

Fast & lightweight HTTP gateway that serves Internet BGP routing database as a JSON REST API.

Image
Networking
API management
Web servers
0

1.1K

letstool/http2prefix repository overview

http2prefix

Lightweight HTTP gateway that resolves IP addresses and AS numbers against live BGP routing tables through a JSON REST API.

Send a POST /api/v1/asprefix request with an IP address or an AS number, get back structured JSON telling you which BGP prefix covers that IP and which AS originates it — or, for an AS number, the full list of announced prefixes and its BGP neighbours.

Two MMDB databases are built automatically from gzipped CSVs served by the letstool CDN and refreshed every 24 hours at 12:00 UTC. No MaxMind license, no BGP collector account, no manual setup.

The binary embeds a web UI (dark/light mode, 15 languages, RTL support) and an OpenAPI 3.1 spec — no external files, no runtime dependencies.

Quick start

docker run -p 8080:8080 letstool/http2prefix:latest

Open http://localhost:8080 to use the web UI, or query the API directly:

# Resolve an IP address to its BGP prefix and originating AS
curl -s -X POST http://localhost:8080/api/v1/asprefix \
  -H "Content-Type: application/json" \
  -d '{"query":"1.1.1.1"}' | jq

# Resolve an AS number to its announced prefixes and BGP neighbours
curl -s -X POST http://localhost:8080/api/v1/asprefix \
  -H "Content-Type: application/json" \
  -d '{"query":"AS13335"}' | jq

Example response — IP address lookup:

{
  "status": "SUCCESS",
  "query_type": "ip",
  "query": "1.1.1.1",
  "answer": {
    "ip": "1.1.1.1",
    "prefix": "1.1.1.0/24",
    "size": "256",
    "origins": [13335]
  }
}

Example response — AS number lookup:

{
  "status": "SUCCESS",
  "query_type": "asnum",
  "query": "AS13335",
  "answer": {
    "asnum": 13335,
    "prefixes": [
      {"prefix": "1.0.0.0/24",     "size": "256"},
      {"prefix": "1.1.1.0/24",     "size": "256"},
      {"prefix": "2606:4700::/32", "size": "2^96"}
    ],
    "peers": [174, 3356, 6939]
  }
}

Query type auto-detection:

  • A valid IPv4 or IPv6 addressprefix2as lookup — returns the matched BGP prefix and all originating AS numbers (MOAS-safe)
  • An AS number in the format AS<n> (case-insensitive: AS13335, as13335) → as2prefix lookup — returns all announced prefixes and the merged list of BGP neighbours

Configuration

CLI flagEnvironment variableDefault
-listen-addrLISTEN_ADDR127.0.0.1:8080
-db-dirDB_DIR/data
-db-urlDB_URL(none)
-license-keyLICENSE_KEY(none)

CLI flags take priority over environment variables.

Proxy is supported via the standard HTTPS_PROXY, HTTP_PROXY, and NO_PROXY environment variables (same behaviour as curl).

docker run -p 8080:8080 \
  -v ./db:/data:rw \
  -e LISTEN_ADDR=0.0.0.0:8080 \
  letstool/http2prefix:latest

Peer sync mode

Set DB_URL to another running http2prefix instance to download both MMDB databases directly from its /db/prefix2as and /db/as2prefix endpoints instead of fetching from the CDN. Useful for air-gapped environments or clusters where only one node hits the CDN.

docker run -p 8080:8080 \
  -e DB_URL=http://upstream-host:8080 \
  -v ./db:/data:rw \
  letstool/http2prefix:latest

Persistent storage

Mount a volume to /data to cache the databases across container restarts:

docker run -p 8080:8080 \
  -e LISTEN_ADDR=0.0.0.0:8080 \
  -v ./db:/data:rw \
  letstool/http2prefix:latest

On restart, if the cached MMDB files are recent enough, they are reloaded immediately without refetching.

Repo

https://github.com/letstool/http2prefix


License

This project is licensed under the Apache License, Version 2.0.

Copyright (c) 2026 letstool.net

See also

ProjectGitHubDocker HubDescription
http2dnsletstool/http2dnsletstool/http2dnsFast & lightweight HTTP gateway that serves DNS queries as a JSON REST API
http2whoisletstool/http2whoisletstool/http2whoisFast & lightweight HTTP gateway that serves WHOIS queries as a JSON REST API
http2rdapletstool/http2rdapletstool/http2rdapFast & lightweight HTTP gateway that serves RDAP queries as a JSON REST API
http2geoipletstool/http2geoipletstool/http2geoipFast & lightweight HTTP gateway that serves IP geolocation database as a JSON REST API
http2certletstool/http2certletstool/http2certFast & lightweight HTTP gateway that serves X.509 certificate inspection as a JSON REST API
http2torletstool/http2torletstool/http2torFast & lightweight HTTP gateway that serves Tor IP database as a JSON REST API
http2sunletstool/http2sunletstool/http2sunFast & lightweight HTTP gateway that serves solar position algorithm as a JSON REST API
http2macletstool/http2macletstool/http2macFast & lightweight HTTP gateway that serves MAC address OUI database as a JSON REST API
http2countryletstool/http2countryletstool/http2countryFast & lightweight HTTP gateway that serves country database as a JSON REST API
http2prefixletstool/http2prefixletstool/http2prefixFast & lightweight HTTP gateway that serves Internet BGP routing database as a JSON REST API
http2registryletstool/http2registryletstool/http2registryFast & lightweight HTTP gateway that serves RIR/NIR Internet registry database as a JSON REST API

BGP routing data sourced from public routing tables via the letstool CDN. This project is not affiliated with any RIR or BGP data provider. “This [Product/Report] utilizes data provided by RouteViews (www.routeviews.org). Use of this data is subject to the CC BY 4.0 license.” “With contributions from network operators and volunteers all over the world, RouteViews collects BGP data by direct peering at Internet Exchange Points (IXPs) or multi-hop peering. Data are archived and made publicly available for download at archive.routeviews.org, lg.routeviews.org, and api.routeviews.org.”

Tag summary

Content type

Image

Digest

sha256:52d3c572b

Size

3.1 MB

Last updated

4 months ago

docker pull letstool/http2prefix