Turn DDoS detector signals into guarded BGP FlowSpec mitigations.
Detectors post attack events over HTTP. prefixd maps the target to your inventory, picks a playbook, checks guardrails, and asks a separate BGP speaker to announce a FlowSpec rule with a mandatory TTL. No detector speaks BGP.
Documentation · Quickstart · Cookbook · Releases
Preferred speaker: rustbgpd, "an API-first BGP daemon in Rust for route servers, route reflectors, and network automation." prefixd drives it over gRPC, and the
rustbgpdCompose profile is the default path. GoBGP stays maintained and selectable. Why rustbgpd
Status: pre-1.0. The /v1/ API is stable within 0.x: a breaking change is
called out in its release's upgrade notes
(API versioning). The latest release,
v0.28.0, adds
source-bound API tokens, recoverable detector admissions and lease-risk
visibility. Shared bearer credentials are removed, and the database upgrade is
one-way: stop every controller sharing the database for one maintenance window.
rustbgpd v0.83.0 or later is required (Compose pins v0.83.0). Follow the
upgrade guide before replacing the
controller or detector credentials.
FastNetMon, Prometheus Alertmanager or any JSON webhook sends attack events. prefixd groups signals per target, weighs corroborating sources and applies the matching playbook. The FastNetMon Community lane exercises the real notify path through FRR. Other adapters have controller integration coverage. These checks do not establish router forwarding enforcement. prefixd can post each new, withdrawn or expired mitigation to Slack, Discord, Teams, Telegram, PagerDuty, Opsgenie or a webhook.
FastNetMon · Generic webhook · Corroborating signals · Alerting
Mitigate a target by hand from the dashboard or API inside the same guardrails, then withdraw it with a reason that the audit log keeps. Rehearse policy in dry-run before you let it announce.
For active rules on rustbgpd, export evidence separates Established-peer dispositions from configured peers without a session. Missing session state is reported as unobserved.
Manual mitigation · Dry-run rollout · Troubleshooting
Drive events, mitigations, the safelist and configuration through the HTTP API
or prefixdctl. The controller serves its OpenAPI document at /openapi.json.
HTTP API · CLI · Authentication
prefixd stops at the speaker. Router receipt and enforcement depend on your router software, address family and import policy. Dated FRR receipts cover FlowSpec BGP receipt through rustbgpd and GoBGP. The separate rustbgpd blackhole receipt covers discard state in zebra and the container kernel. These do not prove packet forwarding; see vendor compatibility for their scope.
With Git and Docker Compose installed, start the controller, dashboard,
PostgreSQL and rustbgpd from published images. Nothing compiles locally. The
first command writes a random database password into .env (mode 0600);
Compose refuses to start without one.
git clone https://github.com/lance0/prefixd.git
cd prefixd
scripts/compose-bootstrap.sh env
docker compose --profile rustbgpd up -d --pull always --no-buildCheck liveness, then bootstrap credentials. The script creates the first
administrator at a hidden password prompt and mints two API tokens into
.prefixd/ (mode 0600): an ingest token for FastNetMon and an operator token
for prefixdctl, which reads it on stdin:
curl http://localhost/v1/health
scripts/compose-bootstrap.sh rustbgpd
docker compose exec -T -e PREFIXD_TOKEN_FILE=/dev/stdin prefixd-rustbgpd prefixdctl status < .prefixd/cli.tokenOpen http://localhost and sign in. nginx serves the dashboard and API on port
80, and rustbgpd publishes BGP on 179. Prometheus (9091) and Grafana (3001) bind
host loopback only. The sample peer uses a documentation address, so it stays
Idle until you configure your edge router in configs/rustbgpd.toml.
The dashboard shows Live through nginx and Polling when the realtime feed is unavailable, including direct Next.js servers. It shows Stale or Offline when no API response has arrived for 15 seconds. See realtime and polling for refresh intervals and ingress requirements. Event history uses 20-row server pages, IP/UUID search and exact source/vector filters. CSV export walks all matching pages; see event listing for live-export and browser-memory limits.
Synthetic data; router installation is unobserved.
For GoBGP, start a fresh deployment with scripts/compose-bootstrap.sh env
and docker compose --profile gobgp up -d --pull always --no-build, run
scripts/compose-bootstrap.sh gobgp, and run controller commands in
prefixd-gobgp. Run one profile at a time: switching
doesn't move active rules or the database's speaker binding. The
quickstart covers configuration storage,
building from source and troubleshooting.
Detector events and manual requests pass the same checks before prefixd saves
intent or calls the speaker. A rejection returns 422 with its reason and sends
nothing to BGP. With the shipped configs/prefixd.yaml,
sign in and request a mitigation for a safelisted address:
curl -sS -c cookies.txt -X POST http://localhost/v1/auth/login \
-H 'Content-Type: application/json' \
-d '{"username":"admin","password":"your_password_here"}'
curl -sS -b cookies.txt -X POST http://localhost/v1/mitigations \
-H 'Content-Type: application/json' \
-d '{"reason":"guardrail check","victim_ip":"10.0.0.5","protocol":"udp",
"dst_ports":[53],"action":"discard","ttl_seconds":120}'{"error":"guardrail violation: IP 10.0.0.5/32 is safelisted"}The other limits in the shipped configuration reject requests the same way:
| Guardrail | Shipped setting | Example rejection |
|---|---|---|
| Safelist | 10.0.0.0/8, 192.168.0.0/16, plus API entries |
IP 10.0.0.5/32 is safelisted |
| TTL | Required, 30 to 1800 seconds | TTL 7200s out of bounds (min=30, max=1800) |
| Ports | At most 5 destination ports | too many ports: 9 (max=5) |
| Active quotas | 20 per customer, 200 per POP, 500 global | quota exceeded: customer (20/20) |
| New mitigation rate | 30 per POP in any 60 seconds; TTL extensions don't count | new mitigation rate exceeded: 30 created at this POP in the last 60s (max_new_per_minute=30) |
| Destination | IPv4 /32 and IPv6 /128 by default |
Manual subnets require explicit prefix bounds and whole-prefix ownership |
Two more rules protect routing state:
- Dry-run:
mode: dry-runruns the full pipeline and records mitigations, metrics and audit entries, but never calls the speaker. Those mitigations stay simulations after a switch to enforced. The shipped config setsmode: enforced; a config that omitsmoderuns in dry-run. - Immutable withdrawal intent: an operator withdrawal, detector unban or TTL expiry saves its rule, actor and reason before the speaker call. A failed or uncertain delete stays pending and retries against the same speaker; it can't turn back into an announcement.
A 201 means prefixd saved intent and the speaker accepted the local request.
It doesn't prove that a router installed the rule. The running controller
enforces TTLs. With the shipped rustbgpd config, rules are
leased: if prefixd stops
while rustbgpd stays up, rustbgpd withdraws them within one lease (60 seconds),
and prefixd re-adds the ones still desired when it returns. With GoBGP, or
leased_flowspec: false, rules stay announced until prefixd returns.
Guardrail settings · Withdrawal recovery · Dry-run rollout
CI publishes the controller and dashboard images to ghcr.io/lance0/prefixd
and ghcr.io/lance0/prefixd-dashboard. Pin a controller and dashboard built
from the same revision.
- Run the containers: follow image selection and the deployment guide.
- Build from source: Rust 1.89 or later and PostgreSQL 14 or later.
cargo build --releasebuildsprefixdandprefixdctlwith both speaker adapters; see bare-metal deployment and contributing. - Before production: set up authentication, TLS and router import policy. Run one controller per POP and speaker target, and read the upgrade guide before changing either.
prefixd decides what to mitigate; rustbgpd owns the BGP sessions. The two meet at a narrow, tested boundary:
- Typed gRPC calls: prefixd adds, deletes and lists FlowSpec rules through rustbgpd's injection and RIB services, on an owner-only Unix socket locally or verified mTLS remotely. Every mutation returns an explicit outcome.
- Reconciliation restores lost rules: rustbgpd holds injected rules in its process. After a speaker restart, prefixd's database still holds the desired state, and the next reconciliation poll (every 30 seconds in the shipped config) re-adds missing rules.
- Qualified versions: prefixd needs rustbgpd v0.83.0 or later, including for VPN FlowSpec, and Compose pins v0.83.0. prefixd refuses to start against an older daemon. CI runs the lifecycle, TTL and restart suite against the immutable v0.83.0 pin and checks that startup refuses v0.82.0.
This qualifies the controller-to-speaker boundary on Linux amd64. It says nothing about router enforcement.
rustbgpd README · rustbgpd docs · Speaker backends · ADR 023
Start with the documentation index, or go to your task:
| Task | Guide |
|---|---|
| Run it for the first time | Quickstart · Cookbook |
| Connect a detector | FastNetMon · Generic webhook · Correlation |
| Send alerts to chat or paging | Alerting |
| Configure, deploy or upgrade | Configuration · Deployment · Upgrading |
| Automate | HTTP API · CLI · API versioning |
| Choose or operate a speaker | Speaker backends · Vendors · Troubleshooting |
| Check the evidence | Profile qualification · Benchmarks (historical) |
| Understand or contribute | Architecture · Decisions · Contributing · Roadmap |
| Report a problem | Issues · Security · Changelog |
MIT. See LICENSE.



