prefixdctl is the command-line tool for interacting with prefixd.
The CLI is built alongside the daemon:
cargo build --release
./target/release/prefixdctl --helpOr use the Docker image:
docker run --rm ghcr.io/lance0/prefixd:latest prefixdctl --helpexport PREFIXD_API=http://localhost # API endpoint (nginx entrypoint)
export PREFIXD_API_TOKEN=your-token-here # Bearer tokenprefixdctl -a http://localhost -t $TOKEN <command>
# Direct daemon access (without nginx)
prefixdctl -a http://127.0.0.1:8080 -t $TOKEN <command>| Option | Env Var | Description |
|---|---|---|
-a, --api |
PREFIXD_API |
API endpoint URL |
-t, --token |
PREFIXD_API_TOKEN |
Bearer token for authentication |
-f, --format |
- | Output format: table (default) or json |
# Overview of daemon status
prefixdctl status
# Example output:
# prefixd v0.14.0 (iad1)
# Status: healthy
# Uptime: 2d 4h 30m
# Active mitigations: 12
# BGP sessions: 2/2 established# BGP session status
prefixdctl peers
# Example output:
# PEER STATE UPTIME
# 10.0.0.1 Established 2d 4h
# 10.0.0.2 Established 2d 4h# All mitigations
prefixdctl mitigations list
# Filter by status
prefixdctl mitigations list --status active
prefixdctl mitigations list --status expired
# Filter by customer
prefixdctl mitigations list --customer acme
# Combine filters
prefixdctl mitigations list --status active --customer acme
# Limit results
prefixdctl mitigations list --limit 50
# JSON output
prefixdctl -f json mitigations listprefixdctl mitigations get <id>
# Example output:
# ID: abc123
# Status: Active
# Customer: acme
# Destination: 203.0.113.10/32
# Protocol: UDP
# Ports: !53
# Action: police (10 Mbps)
# TTL: 120s (expires in 45s)
# Created: 2026-01-18T10:30:00Z# Withdraw with reason
prefixdctl mitigations withdraw <id> --reason "false positive"
# Example output:
# Mitigation abc123 withdrawn# Interactive password prompt
prefixdctl operators create --username admin --role admin
# With password flag (prompts for password)
prefixdctl operators create --username jsmith --role operator --password
# Roles: admin, operator, viewerprefixdctl operators list
# Example output:
# USERNAME ROLE CREATED
# admin admin 2026-01-15T08:00:00Z
# jsmith operator 2026-01-16T14:30:00ZThe safelist prevents mitigations on protected IPs (infrastructure, etc.).
prefixdctl safelist list
# Example output:
# PREFIX REASON ADDED BY ADDED
# 10.0.0.1/32 Router loopback admin 2026-01-15
# 10.0.0.2/32 DNS resolver admin 2026-01-15prefixdctl safelist add 10.0.0.1/32 --reason "router loopback"prefixdctl safelist remove 10.0.0.1/32Hot-reload inventory and playbooks without restarting:
prefixdctl reload
# Example output:
# Configuration reloaded
# Inventory: 150 customers, 2340 assets
# Playbooks: 12 policies# Requires DATABASE_URL to be set
prefixdctl migrationsHuman-readable tables:
prefixdctl mitigations list
# ID STATUS CUSTOMER DESTINATION ACTION TTL
# abc123 Active acme 203.0.113.10/32 police 45s
# def456 Active acme 203.0.113.20/32 discard 120sMachine-readable JSON:
prefixdctl -f json mitigations list
# [
# {
# "id": "abc123",
# "status": "active",
# "customer_id": "acme",
# "dst_prefix": "203.0.113.10/32",
# "action": "police",
# "rate_bps": 10000000,
# "ttl_remaining_seconds": 45
# }
# ]| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Connection failed |
| 3 | Authentication failed |
| 4 | Not found |
| 5 | Validation error |
# Check mitigation details
prefixdctl mitigations get abc123
# Withdraw if false positive
prefixdctl mitigations withdraw abc123 --reason "customer confirmed legitimate traffic"
# Add to safelist to prevent future mitigations
prefixdctl safelist add 203.0.113.10/32 --reason "high-traffic legitimate service"# Watch active mitigations
watch -n 5 'prefixdctl mitigations list --status active'
# Check BGP session health
prefixdctl peers
# Get detailed status
prefixdctl status# JSON output for scripting
ACTIVE=$(prefixdctl -f json mitigations list --status active | jq length)
echo "Active mitigations: $ACTIVE"
# Bulk operations
prefixdctl -f json mitigations list --status active | \
jq -r '.[].id' | \
xargs -I {} prefixdctl mitigations withdraw {} --reason "bulk cleanup"