Why reviewing the policy text is not enough
Capture advertised routes per peer
jq:
BASH
#!/usr/bin/env bash
# Capture IPv6 prefixes advertised to each BGP peer on FRR. Read-only.
# Usage: ./capture.sh before (or: ./capture.sh after)
set -euo pipefail
out="${1:?usage: capture.sh <output-dir>}"
mkdir -p "$out"
for peer in $(vtysh -c 'show bgp ipv6 unicast summary json' | jq -r '.peers | keys[]'); do
vtysh -c "show bgp ipv6 unicast neighbors $peer advertised-routes json" \
| jq -r '.advertisedRoutes // {} | keys[]' \
| sort -u > "out/peer.txt"
done
wc -l "$out"/*.txtipv4 unicast. The Miami incident was IPv6, and IPv6 policy often gets less testing than IPv4 after a migration, but both address families go through the same export path and both can leak.
On other platforms the idea is the same. You want the command that shows routes after export policy is applied, toward one neighbor:
TEXT
# Junos: routes sent to one peer after export policy
show route advertising-protocol bgp 2001:db8::1 table inet6.0
# BIRD 2: routes the export filter passes to a protocol (illustrative protocol name)
birdc show route export peer_ix1
# Cisco IOS XR
show bgp ipv6 unicast neighbors 2001:db8::1 advertised-routes| display json and IOS XR has structured output options depending on release, which saves you from parsing tables with regular expressions. Check what your version supports before you build on it.
One detail to confirm on your platform: whether advertised-routes reads a stored Adj-RIB-Out or recomputes it on request. Either works for diffing, but if the router only keeps the stored view under a specific setting, a capture taken without it can be incomplete. If you run many routers, BMP (BGP Monitoring Protocol, RFC 7854) with Adj-RIB-Out support (RFC 8671) can stream this data to a collector instead of polling each box over SSH.
Diff the captures and fail on additions
before/ and after/ directory, the comparison is a few lines of shell. Sorted files and comm are enough. No extra tooling is needed:
BASH
#!/usr/bin/env bash
# Compare before/after captures. Exit 1 if any peer gains prefixes or appears/disappears.
set -uo pipefail
before="{1:?before dir}"; after="{2:?after dir}"; status=0
for f in "$after"/*.txt; do
peer=(basename "f" .txt)
[ -f "before/peer.txt" ] || { echo "NEW PEER: $peer"; status=1; continue; }
added=(comm -13 "before/peer.txt" "f")
removed=(comm -23 "before/peer.txt" "f")
[ -n "added" ] && { echo "ADDED topeer:"; echo "$added"; status=1; }
[ -n "removed" ] && { echo "REMOVED frompeer:"; echo "$removed"; }
done
for f in "$before"/*.txt; do
[ -f "after/(basename "f")" ] || { echo "PEER GONE:(basename "$f" .txt)"; status=1; }
done
exit "$status"added, and fail on anything left over. The change then has to state what it should advertise, and the router output has to match.
Exact string matching has one gap. If your internal space is an aggregate such as an illustrative 2001:db8:100::/40, a leaked /48 inside it is a different string and only shows up as an addition. It will still fail the gate, but whoever reads the output has to recognize it as internal. A second check that tests every advertised prefix against your internal ranges makes that explicit. Python's standard ipaddress module (subnet_of) handles this in a few lines without new dependencies.
Run the comparison before production, not after
- Apply the new policy on a lab router that receives a realistic routing table, for example through an iBGP session from a route reflector with outbound sessions to dummy peers, then capture and diff against production captures from the old platform.
- Roll out to one router first, with external sessions held down or covered by a strict inbound filter on the peer side where you control both ends, and capture before enabling them.
- Use the platform's dry-run or commit check feature if it can evaluate policy against the current RIB. Many can only check syntax, so confirm what yours actually evaluates.
Reading the output
ADDED to 2001:db8::1: followed by a handful of prefixes. Before approving anything, ask three questions about each added prefix. Is it in the allowlist for this change? Is it inside your internal or infrastructure ranges? Is it more specific than what you announced before? A yes to the second or third question, without a matching allowlist entry, is a stop.
From the support side, these leaks rarely arrive as "BGP problem" tickets. They show up as unrelated users reporting slowness or timeouts toward services that have nothing to do with your network, and the first instinct is to look at the servers. A saved per-peer diff from the last routing change is one of the quickest things to rule in or out.
The practical rule: treat per-peer advertised routes as the test result for any export policy change, capture them on the old platform before you migrate, diff them on the new one before external sessions carry traffic, and let any unexplained addition block the rollout. The scripts are small, read-only, and quick to run, which is cheap compared to finding out from other networks that your router is sending them traffic it cannot deliver.