Insights

Migrated BGP Export Policy to a New Platform? Diff Advertised Routes per Peer

December 5, 2026
0:00
You moved BGP export policy to a new router platform, or from hand-written config into an automation pipeline. The config review looked fine, the sessions came up, and traffic still flows. That tells you very little about what each external peer is now receiving. Comparing the advertised routes per peer, before and after, gives you a direct answer. Cloudflare's route leak in Miami on January 22, 2026 shows why this matters. An automated routing policy configuration error on a core router let internal IPv6 prefixes, which were meant to stay local, be redistributed across the backbone and advertised to external BGP peers in Miami. Other networks picked those routes through normal best-path selection, sent traffic toward Miami, and much of it was dropped by firewall filters that only accepted Cloudflare customer traffic. The incident lasted about 25 minutes and affected IPv6 traffic globally. If you want the mechanics of why leaked prefixes cause drops instead of just slower paths, see how internal firewalls made a route leak worse. This guide covers how to catch that kind of leak before rollout.
Export policy is translated, not copied. Each platform has its own semantics for match conditions, default actions, prefix-list length matching, and what happens when a term references a set that is empty or missing. A policy that rejected everything not explicitly allowed on the old platform can end up accepting more on the new one. Common causes are a different final default, a community match that the new platform evaluates differently, or a redistribution rule that now feeds internal routes into BGP. A template diff shows you what changed in the text. It does not show you what the router computes from that text against the real routing table. The second view, called the Adj-RIB-Out (the set of routes BGP will send to a given neighbor after outbound policy), is the one your peers see. That is the thing to compare. Prefix counts alone are a weak check. A peer can receive the same number of routes before and after while one customer aggregate gets swapped for an internal /48. Compare the actual prefixes, peer by peer.
The capture should be read-only, scripted, and produce one sorted file per peer so that diffing is trivial. On FRR, the JSON output makes this easy with 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"/*.txt
Run the same thing for ipv4 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
The text output of these commands needs parsing into one prefix per line. Junos supports | 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.
With a 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 prefixes fail the check because they are where leaks show up. Removed prefixes are printed but do not fail by default. A removal usually means lost reachability for something you announce, which is bad but visible quickly through monitoring and customer reports. An addition to an external peer can pull other networks' traffic toward you, and nothing on your side alerts until links congest or firewalls start dropping. Tighten the removal rule if your environment needs it. Some changes are supposed to add prefixes, like a new customer block or a new anycast range. Do not loosen the gate for those. Put the expected additions into the change request as a per-peer allowlist file, filter them out of 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.
Capturing on a production router after the new policy is live only tells you how long the leak has been running. The comparison needs to run where a bad result costs nothing. Practical options, from least to most effort:
  1. 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.
  2. 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.
  3. 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.
Whichever you choose, keep the old-platform capture as the baseline. When you change platform and automation at the same time, the baseline from the old setup is the only reference you have for what each peer used to receive. Two defaults are worth knowing here. Routers that follow RFC 8212 do not send or accept eBGP routes when no policy is attached, which protects you if a policy fails to apply. Not every platform or version behaves this way, and a policy that exists but is too permissive passes straight through that protection. The diff catches both cases. For more on the missing-policy case, see the separate article on default eBGP behavior after moving to automation.
An illustrative failing run looks like this in shape: a line 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.

Join My Newsletter & Get Updates!

Get notified whenever a new technical guide, server infrastructure breakdown, or personal reflection goes live, plus a curated weekly digest.