A command-line tool and API service for querying historical RPKI ROA (Route Origin
Authorization) data. It crawls daily ROA dumps from RIPE
(https://ftp.ripe.net/rpki/), stores them in a memory-efficient prefix trie, and
serves a REST API for looking up ROA history by prefix, ASN, max-length, date, and
currency status.
- Historical ROA data — Full history from 2011 onward, sourced from all 5 RIR TALs (Afrinic, APNIC, ARIN, LACNIC, RIPE NCC)
- Zero-copy mmap trie —
prefix-trie+ rkyv backed v2 storage; the raw local archive is memory-mapped rather than loaded into heap memory - Legacy transition mode —
.bin/.bin.gzinputs retain the v1ipnet-triein-memory backend;.rkyvinputs select zero-copy mmap automatically - REST API — Query by prefix, ASN, max-length, date, and current/expired status
- Incremental updates — Background thread fetches new data every 8 hours
- Backup to R2/S3 — Automatic backup of the trie to Cloudflare R2 or any S3-compatible storage
- One-command bootstrap — Download a pre-built trie and start serving immediately
- Docker deployment — Multi-arch image (
linux/amd64,linux/arm64)
cargo install wayback-rpkibrew install bgpkit/tap/wayback-rpkiUsing cargo-binstall
cargo binstall wayback-rpkidocker run -p 40065:40065 bgpkit/wayback-rpki:latestStart the API with a one-command bootstrap (downloads the published object from
spaces.bgpkit.org):
wayback-rpki serve --bootstrapThis reads broker/snap/manifest.json, downloads the newest object it names, checks the bytes
against the content id, and serves that file on 0.0.0.0:40065. Nothing is built locally: the
object is the finished artifact. A snap object is immutable, so this mode serves a fixed
coverage window; restart it on the next object to move forward.
Naming a .rkyv path instead keeps the 1.x behaviour: the platform-agnostic
roas_trie.jsonl.gz transport is streamed through a builder into a local .rkyv, memory
mapped, and updated every 8 hours from the archive.
wayback-rpki [OPTIONS] <COMMAND>
Commands:
rebuild Rebuild the entire RPKI ROA history data from scratch
update Find new ROA files and apply incremental changes
search Search for ROAs in history
fix Fill known historical data gaps
export Export a v2 rkyv archive as a portable JSONL transport file
serve Start the API server
Options:
<PATH> Trie archive path; `.rkyv` uses mmap and `.bin[.gz]` uses legacy in-memory mode [default: roas_trie.rkyv]
-b, --bootstrap Download bootstrap file if the data file doesn't exist
--env <ENV> Path to an environment variable file
-h, --help Print help
-V, --version Print version
Crawls all ROA dumps from RIPE since 2011 and builds the trie from scratch.
wayback-rpki rebuild --from 2020-01-01 --until 2024-12-31Options: --tal (filter to one RIR), --from, --until, --chunks (parallelism,
defaults to CPU count).
Fetches only new ROA files since the trie's latest date:
wayback-rpki updateQuery ROAs from the command line. Outputs a markdown table.
# Search for exact prefix
wayback-rpki search --prefix 1.1.1.0/24
# Search by ASN, only current ROAs
wayback-rpki search --asn 13335 --current true
# Search with date filter
wayback-rpki search --prefix 1.1.1.0/24 --date 2020-06-01
# Include supernets and subnets (non-exact matching)
wayback-rpki search --prefix 193.0.14.0/24 --exact falseOptions: --asn, --prefix, --max-len, --date (YYYY-MM-DD), --current (bool),
--exact (bool, default true).
Export a local v2 .rkyv archive to the portable JSONL transport format. Use a .jsonl.gz
output path for gzip compression. This supports backups and transfers across architectures; it
does not modify the source archive.
wayback-rpki export --output roas_trie.jsonl.gz roas_trie.rkyvwayback-rpki serve --bootstrap --host 0.0.0.0 --port 40065Options: --host (default 0.0.0.0), --port (default 40065), --backup-to (additional
backup destination path or S3 URL).
wayback-pg maintains the full RPKI ROA and ASPA history from RIPE in PostgreSQL as
object-grain rows with SCD-2 spans, so the archive can be queried in SQL. The trie
backend above carries ROA history only; ASPA exists on the PostgreSQL side. This
binary is additive; the trie commands are unaffected.
# 1. Create the schema. Both files are idempotent; re-apply them to pick up
# schema updates.
psql "$PG_CONFIG" -f pg/001_schema.sql -f pg/002_aspa.sql
# 2. Load the history once (explicit range, both ends inclusive).
wayback-pg backfill --pg-config "$PG_CONFIG" --from 2015-03-10 --until 2026-09-30
# 3. Then keep it current (through yesterday UTC by default).
wayback-pg update --pg-config "$PG_CONFIG"backfillandupdateingestroas.csv.xz(from 2015-03-10) andoutput.json.xz(ASPA, from 2023-10-11); restrict with--typesand--tal. ASPA is carried by this PostgreSQL line only — the trie backend ingests the ROA artifact alone.updateresumes after each TAL's latest observed day recorded in thesource_fileledger. On an empty database the ROA pass stops with an error asking for abackfillfirst — and with the default--types roa,aspathe ROA pass runs first, soupdateexits there without reaching the ASPA pass. Start with abackfill, or--types aspato walk from the archive's ASPA era (2023-10-11).- Runs take a PostgreSQL advisory lock: a second concurrent run exits instead of racing, and re-running an already-ingested day is idempotent.
- Unlisted days: a
backfillrecords them in the ledger asmissing(gap_class) and continues; anupdaterecords the day, stops that family's walk for the TAL (the resume cursor stays before the gap, so the next run retries it), and the run reports a failing status. One exception: an ASPA walk that starts at the ASPA era with no observation yet records the pre-observation days asera_start, which neither stops the walk nor fails the run. - The schema ships read-side views for common queries:
roa_tuple_view(merged observation spans per prefix/origin/max-length),roa_change_event_view(appeared / maxlen_changed / publication_flap / cert_window_changed),roa_counts_viewandaspa_counts_view(per-TAL/day source counts).
PostgreSQL is the system of record, and the v3 and v4 APIs read it. Alongside it, the same
history is published as a bgpkit-snap object: one immutable file, addressed by its content
id, with a small manifest as the only mutable key. The object is a pure function of the
Parquet table that export-spans already writes, so this path never reads PostgreSQL and a
failed build leaves the previous file serving.
# build from the daily export and publish it
wayback-pg snap-build \
--spans /var/lib/wayback/spans/roa-spans.parquet \
--publish s3://spaces/broker/snap/
# compare a published object with PostgreSQL, prefix by prefix
wayback-pg snap-check \
--pg-config "$PG_CONFIG" \
--object s3://spaces/broker/snap/roas-<content id>.snap \
--sample 200Layout and contract:
broker/snap/roas-<content id>.snap immutable, one object for both address families
broker/snap/manifest.json the only key that changes
The manifest records, per object: the key, the content id, byte size and entry count (split
by family), the interval record count, the coverage window, the build time, and the sha256 of
the Parquet it was built from. A consumer reads the manifest, then fetches the object it
names. There is no latest alias, because an alias is a promise the object cannot verify.
The value type is bgpkit.roa-set:v1: for each prefix, one record per (max_len, origin)
with the day intervals during which the archive shows that authorization in effect. Ask a
question by opening the object and matching the prefix you care about.
What an unattended run will not do: publish over an unchanged source (the Parquet hash is
checked first), publish a table that lost more than one percent of its prefixes, or publish
a coverage window that moved backwards. Both of the latter are the shape of a broken export,
and the previous object should keep serving. --force publishes anyway, for a deliberate
rebuild.
| file | reader | state |
|---|---|---|
broker/snap/manifest.json + roas-*.snap |
2.x, and anything that can read a snap object | current, published daily |
broker/roas_trie.jsonl.gz |
1.x binaries, .rkyv paths |
current, published daily |
broker/roas_trie.bin.gz |
v1 bincode binaries only | frozen at 2026-08-24 |
The v1 bincode file stopped being produced when the v1 writer was removed; nothing in 2.x can write that format. It remains in the bucket so an old client does not get a 404, but it is a snapshot of August 2026. A client that old should be upgraded, not fed.
wayback-rpki /var/lib/wayback/roas.snap serve --bootstrap --port 40065With --bootstrap and no file at the path, serve fetches
https://spaces.bgpkit.org/broker/snap/manifest.json, downloads the newest object it names,
and checks the bytes against the content id before moving the file into place. A mismatch
deletes the partial download and stops, rather than serving something the manifest did not
publish. There is no local build step: the object is already the finished artifact.
The default path is now roas_trie.snap, so a bare serve --bootstrap gets the object.
The older bootstrap, roas_trie.jsonl.gz, stays alive for binaries from before 2.0: they
cannot read a snap object at all. The daily publish keeps it current from the same grouped
rows the object is built from, so the two artifacts cannot describe different history:
wayback-pg snap-build --spans .. --publish s3://spaces/broker/snap/ \
--legacy-jsonl s3://spaces/broker/roas_trie.jsonl.gz
It is 13.6 MB against the object's 223 MB, but it costs a local build that peaks at a few
hundred megabytes of RAM, so it is the compatibility path, not the recommended one. Naming a
.rkyv path still selects it: wayback-rpki roas_trie.rkyv serve --bootstrap behaves exactly
as it did in 1.x.
serve accepts a published object in place of a trie archive:
wayback-rpki /var/lib/wayback/roas.snap serve --port 40065The path decides the backend: .snap is a v3 object, .rkyv is the v2 trie, anything else
is the v1 legacy archive. The query surface is the same on all three, and
tests/snap_backend_equivalence.rs holds the answers equal for every query shape the API
exposes, including the "subtree of the shortest covering prefix" rule and the expired filter.
In the container the entrypoint already names the subcommand, so override the entrypoint to serve an object:
docker run --entrypoint /usr/local/bin/wayback-rpki \
-v /srv/wayback:/data -p 40065:40065 \
wayback-rpki:latest /data/roas.snap serve --host 0.0.0.0 --port 40065What is different about serving a v3 object: there is no updater. An object is immutable and
addressed by content id, so a refresh means publishing the next object and restarting the
server on it. current=true is answered from the coverage window the object declares, so an
object built without a window is refused at open rather than answered with a guessed date.
Retention keeps the newest --keep-daily objects (default 30) plus the last object of each
UTC month, and deletes only keys the manifest no longer names. deploy/ holds the unit, the
timer, and the publish script a host installs to run this on a schedule; every site-specific
value in them comes from an environment file. wayback-snap.timer runs the
publish daily at 09:00 UTC, after wayback-update (07:30) and wayback-spans (about 08:30).
Rollback is stopping the timer: no serving path reads these objects.
Query ROAs with optional filters. All parameters are optional.
| Parameter | Type | Default | Description |
|---|---|---|---|
prefix |
string | — | IP prefix to search, e.g. 1.1.1.0/24 |
asn |
integer | — | Filter by origin ASN (exact match) |
max_len |
integer | — | Filter by ROA max-length value |
date |
string | — | Date filter (YYYY-MM-DD); returns ROAs active on that date |
current |
boolean | — | true: only current ROAs; false: only expired ROAs |
exact |
boolean | true |
true: exact prefix match only; false: include supernets and subnets |
page |
integer | 0 |
Page number (0-indexed) |
page_size |
integer | 100 |
Items per page (max 1000) |
Response:
{
"count": 1,
"error": null,
"data": [
{
"prefix": "1.1.1.0/24",
"max_len": 24,
"asn": 13335,
"date_ranges": [
["2018-04-05", "2026-04-03"],
["2026-04-05", "2026-06-12"],
["2026-06-14", "2026-07-09"]
],
"current": true
}
],
"meta": { "latest_date": "2026-07-09" },
"page": 0,
"page_size": 100
}Examples:
# Exact prefix search (default)
curl "http://localhost:40065/search?prefix=1.1.1.0/24"
# Search by ASN, current ROAs only, first 10
curl "http://localhost:40065/search?asn=13335¤t=true&page_size=10"
# ROAs active on a specific date
curl "http://localhost:40065/search?prefix=1.1.1.0/24&date=2020-06-01"
# Include supernets and subnets
curl "http://localhost:40065/search?prefix=193.0.14.0/24&exact=false"Error handling: Malformed prefix or date values return 400 Bad Request with a
JSON error body (e.g., {"error": "invalid prefix"}).
Returns trie statistics.
{
"ipv4_roas_count": 820313,
"ipv6_roas_count": 279184,
"latest_date": "2026-07-09"
}The crate can be used as a Rust library. The key types and functions are re-exported at the crate root:
use wayback_rpki::{crawl_tal_after, parse_roas_csv, get_tal_urls, RoaEntry, RoaFile};crawl_tal_after(tal_url, from, until) -> Vec<RoaFile>— Discover ROA dump files for a TAL within a date range.parse_roas_csv(url) -> Result<Vec<RoaEntry>>— Download and parse a singleroas.csv.xzfile.get_tal_urls(tal: Option<String>) -> Vec<String>— Get RIPE RPKI TAL URLs for one or all RIRs.
use wayback_rpki::{RoasTrie, RoasTrieMut};
use ipnet::IpNet;
use chrono::NaiveDate;
// Open a pre-built trie (memory-mapped, zero-copy)
let trie = RoasTrie::open("roas_trie.rkyv")?;
// Search with filters (exact=true by default)
let results = trie.search(
Some("1.1.1.0/24".parse().unwrap()), // prefix
Some(13335), // origin ASN
None, // max_len
None, // date
Some(true), // current only
true, // exact prefix match
);
for entry in &results {
println!("{} AS{} max_len={}", entry.prefix, entry.origin, entry.max_len);
for (start, end) in &entry.dates_ranges {
println!(" active: {} to {}", start, end);
}
}
// RPKI validation
use wayback_rpki::RpkiValidation;
let date_ts = NaiveDate::from_ymd_opt(2024, 1, 1).unwrap()
.and_hms_opt(0, 0, 0).unwrap().and_utc().timestamp();
let validation = trie.validate(&"1.1.1.0/24".parse().unwrap(), 13335, date_ts);
// → RpkiValidation::Valid
// Build / update (mutable builder), then serialize
let mut builder = RoasTrieMut::new();
builder.process_entries(&entries, true)?;
builder.dump("roas_trie.rkyv")?;| Type | Role |
|---|---|
RoasTrie |
Read-only query handle over an rkyv archive (mmap or in-memory) |
RoasTrieMut |
Mutable builder: new, load_mut, process_entries, update, dump |
RoasTrie::open(path) |
Memory-map an archive (near-zero heap usage) |
RoasTrieMut::load_mut(path) |
Load for mutation (update / fix flows) |
RoasTrie::search(...) |
Query with filters |
RoasTrie::lookup_prefix(prefix) |
All ROAs covering a prefix (super + subnets) |
RoasTrie::validate(...) |
RPKI validation → Valid / Invalid / Unknown |
The on-disk v2 format is a raw rkyv archive (RoasTrieData with header
metadata and a JointPrefixMap). Raw .rkyv files are mmap-ready and
platform-specific — they are never used for transport or backup.
Transport/backup format: JSONL.gz — one line per (prefix, max_len, origin)
ROA record with compressed date ranges. Platform-agnostic, streamable, and
human-debuggable (zcat roas_trie.jsonl.gz | head | jq .).
During the v2 transition, .bin/.bin.gz paths retain the legacy in-memory
backend. A missing roas_trie.rkyv is auto-generated, in order:
- Local sibling
.bin.gz/.bin→ convert - Remote
roas_trie.jsonl.gz→ stream-import → dump rkyv (preferred, ~200 MB peak RAM) - Remote
roas_trie.bin.gz→ download → convert (legacy fallback)
Explicit conversion is also available as
wayback-rpki convert --from roas_trie.bin.gz roas_trie.rkyv.
| compress_dates() | Merge consecutive dates into ranges |
| fill_gaps() | Fill known historical data gaps |
The serve subcommand supports the following environment variables:
| Variable | Description |
|---|---|
WAYBACK_BACKUP_TO |
Backup destination (r2://bucket/key for S3/R2, or local path). Backups are written as platform-agnostic JSONL.gz transport files streamed from the live mmap archive. |
WAYBACK_BACKUP_HEARTBEAT_URL |
URL to ping after successful backup (e.g., UptimeRobot) |
AWS_REGION |
S3/R2 region (required for R2 backups) |
AWS_ENDPOINT |
S3/R2 endpoint (required for R2 backups) |
AWS_ACCESS_KEY_ID |
S3/R2 access key (required for R2 backups) |
AWS_SECRET_ACCESS_KEY |
S3/R2 secret key (required for R2 backups) |
# Build
docker build -t wayback-rpki .
# Run (bootstraps automatically)
docker run -d -p 40065:40065 wayback-rpki
# Run with R2 backup
docker run -d -p 40065:40065 \
-e WAYBACK_BACKUP_TO=r2://spaces/broker/roas_trie.bin.gz \
-e AWS_REGION=auto \
-e AWS_ENDPOINT=https://<account>.r2.cloudflarestorage.com \
-e AWS_ACCESS_KEY_ID=<key> \
-e AWS_SECRET_ACCESS_KEY=<secret> \
wayback-rpkiThe Docker image is also published to Docker Hub:
docker pull bgpkit/wayback-rpki:latestROA data is crawled from the RIPE RPKI archive:
https://ftp.ripe.net/rpki/<tal>/YYYY/MM/DD/roas.csv.xz
Supported TALs: afrinic, apnic, arin, lacnic, ripencc.
MIT