Free — no signup required

BGP Flowspec: The Global Firewall

3 min read

Weaponizing BGP for Defense

Standard BGP tells routers: "Send traffic destined for IP block X toward next-hop Y." It operates purely on destination. BGP Flowspec (Flow Specification, RFC 5575 / RFC 8955) extends this model fundamentally: it allows you to distribute traffic filtering rules — essentially firewall ACLs — via BGP to all your routers simultaneously.

A Flowspec rule is a BGP route with a special address family (AFI 1, SAFI 133 for IPv4). Instead of encoding a destination prefix, it encodes a traffic flow specification — a set of match conditions — plus an action.

Match Conditions Flowspec Supports:

Match Field Example
Destination Prefix 198.51.100.0/24
Source Prefix 203.0.113.0/24
IP Protocol TCP, UDP, ICMP
Source Port port 53
Destination Port port 80, port 443
Packet Length < 64 bytes (common in amplification attacks)
TCP Flags SYN only (SYN flood detection)
DSCP / ToS Traffic class markers

Actions (BGP Extended Communities):

Action Effect
traffic-rate 0 Drop all matching traffic (rate limit to 0 bps)
traffic-rate 1000000 Rate limit to 1 Mbps
redirect VRF Redirect to a scrubbing center VRF
traffic-marking DSCP Re-mark DSCP for QoS treatment

The DDoS Response Workflow:

Without Flowspec, responding to a DDoS attack requires logging into every border router, writing ACLs, and applying them — a process that takes 30–60 minutes and is error-prone under pressure.

With Flowspec:

  1. Your DDoS detection system identifies an attack: UDP flood from 203.0.113.0/24 targeting port 53 on your DNS servers.
  2. It generates a single Flowspec BGP announcement: "Match: src=203.0.113.0/24, dst-port=53, proto=UDP → Action: drop"
  3. This announcement propagates via BGP to all your border routers in seconds.
  4. All routers simultaneously begin dropping the attack traffic at the edge — before it consumes internal bandwidth.
  5. When the attack stops, you withdraw the Flowspec route. All routers revert to normal behavior instantly.

Security Considerations for Flowspec:

Flowspec is powerful enough to black-hole your entire network if misused. A Flowspec rule matching 0.0.0.0/0 with action traffic-rate 0 would drop all traffic everywhere. Best practices:

  • Accept Flowspec only from trusted peers (your own route reflectors or a contracted DDoS mitigation provider).
  • Implement validation: reject Flowspec rules that match overly broad prefixes.
  • Use BGP communities to scope Flowspec rules to specific PoPs rather than the entire network.
  • Log all Flowspec rule installations and withdrawals for audit purposes.
Interview Tip

Interviewers at ISPs and large cloud providers often ask: "How would you respond to a volumetric DDoS attack targeting a specific port across all your PoPs?" The answer that distinguishes senior candidates is Flowspec: describe how a single BGP announcement can distribute a drop rule to all border routers simultaneously, contrast it with the manual ACL approach, and mention the security controls needed to prevent Flowspec from being weaponized against your own network.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free