· 7 min read

Automating RTBH: BGP Blackhole Communities Guide

Automating RTBH (remotely triggered blackhole) means your DDoS detector announces a /32 (or /128) for the attacked IP to your upstream with a blackhole BGP community, and withdraws it automatically when the attack is over. The upstream then drops all traffic to that address at its edge, so the flood never reaches your links.

RTBH is crude, but it is fast and nearly universal. This guide covers how it works, how to wire it up on common platforms, how to handle removal, and where it hurts you.

How RTBH works

  1. Your detector sees an IP exceeding a bps or pps threshold in flow data.
  2. It announces a host route for that IP to your router, usually over iBGP.
  3. Your router re-announces the route to the upstream with the upstream's blackhole community, and often NO_EXPORT.
  4. The upstream sets the next hop to a discard interface. Traffic toward that IP is dropped before it crosses your transit link.

The standardized community is BLACKHOLE = 65535:666 (RFC 7999). Many providers also define their own, such as <their-ASN>:666 or another value in their documentation. This article uses 64496:666 for a documentation-range upstream (AS64496). Always use the value your provider publishes.

The result is that the victim IP goes completely offline. You are trading one host's availability for the stability of everything else on the link. That is the core trade-off of RTBH.

Check upstream support first

Before you automate anything, confirm these points with each transit provider and IXP:

Test with a spare IP in a maintenance window. Confirm the route is accepted and that traffic really stops, using traceroute from an outside looking glass.

Configuration examples

All examples use documentation addresses. Your own space is 192.0.2.0/24, your ASN is AS64500, and the upstream is AS64496.

Juniper (Junos): accept triggers from the detector, tag, and export

Your detector announces over iBGP with an internal trigger community, 64500:666. The edge router validates the route, rewrites the next hop to discard, and adds the upstream community.

set policy-options community RTBH-TRIGGER members 64500:666
set policy-options community UPSTREAM-BH members 64496:666
set policy-options community NO-EXPORT members no-export

set policy-options policy-statement FROM-DETECTOR term BH from route-filter 192.0.2.0/24 prefix-length-range /32-/32
set policy-options policy-statement FROM-DETECTOR term BH from community RTBH-TRIGGER
set policy-options policy-statement FROM-DETECTOR term BH then community add UPSTREAM-BH
set policy-options policy-statement FROM-DETECTOR term BH then community add NO-EXPORT
set policy-options policy-statement FROM-DETECTOR term BH then next-hop discard
set policy-options policy-statement FROM-DETECTOR term BH then accept
set policy-options policy-statement FROM-DETECTOR term DEFAULT then reject

set policy-options policy-statement TO-UPSTREAM term BH from community UPSTREAM-BH
set policy-options policy-statement TO-UPSTREAM term BH then accept

The route-filter line is the most important safety control. It stops a bad trigger from blackholing anything other than a single host in your own space.

Cisco IOS-XE: static null route redistributed with a tag

ip route 192.0.2.66 255.255.255.255 Null0 tag 666

route-map RTBH-OUT permit 10
 match tag 666
 set community 64496:666 no-export additive

router bgp 64500
 address-family ipv4
  redistribute static route-map RTBH-OUT
  neighbor 198.51.100.1 send-community

This works well for manual triggers. For automation, have your detector peer with the router and apply an inbound route-map equivalent to the Junos one above.

MikroTik RouterOS v7

/ip route add dst-address=192.0.2.66/32 blackhole comment="rtbh"

/routing filter rule add chain=upstream-out \
  rule="if (dst in 192.0.2.0/24 && dst-len == 32 && blackhole) { append bgp-communities 64496:666; accept }"

RouterOS filter syntax has changed between v7 releases. Verify it on your version in a lab first, and keep a final reject rule in the chain so that only intended routes leave.

Linux with BIRD 2 as the trigger speaker

If you want a simple host that announces routes to your router, a static route with communities is enough:

protocol static rtbh4 {
    ipv4;
    route 192.0.2.66/32 blackhole {
        bgp_community.add((64500,666));
    };
}

Add or remove the route line and run birdc configure. Detection tools usually do the same thing through ExaBGP, GoBGP, or a built-in BGP speaker.

Automatic removal: the hard part

Withdrawing is trickier than announcing. Once the upstream is dropping traffic to the IP, your flow data no longer shows the attack. You can't tell whether it has stopped. Practical approaches:

Whichever tool you use, check how it handles expiry, whether the state survives a restart, and what happens to announced routes if the detector dies. A detector that crashes after announcing and never withdraws can leave a customer offline for days.

Common mistakes and risks

When to move beyond RTBH

Use RTBH as a safety valve for volumetric floods that threaten your uplinks. For better granularity:

Where NixMon fits

NixMon detects attacks from NetFlow v5/v9, IPFIX, or sFlow with per-IP and per-prefix bps/pps thresholds, and can respond with BGP blackhole (RTBH) or BGP FlowSpec announcements, an on-prem NixGuard firewall, or NixGuard Edge. You can test the full chain, from detection through BGP announcement to your router's policy, in the 15-day free trial. No credit card is needed. Run it first against a spare test IP before you rely on it for production.

Quick deployment checklist

  1. Get the blackhole community, prefix length rules, and limits in writing from each upstream.
  2. Build an inbound policy on the trigger session: own space only, /32 and /128 only, specific trigger community.
  3. Add the upstream community and NO_EXPORT on export.
  4. Create an exclusion list for critical IPs.
  5. Set expiry timers and back-off, and alert on long-running blackholes.
  6. Test announce, traffic drop, and withdraw end to end.
  7. Define an escalation path to FlowSpec or scrubbing for repeat targets.

Frequently asked questions

What is the standard BGP community for RTBH?

RFC 7999 defines the well-known BLACKHOLE community 65535:666. Many providers also publish their own ASN-specific blackhole community. Always use the value in your upstream's documentation, and confirm whether they accept 65535:666.

Why do upstreams accept a /32 for RTBH when they filter long prefixes?

Providers usually make an exception for routes tagged with their blackhole community. They typically still validate that the prefix belongs to you, based on IRR objects or your AS-SET, so register your routes properly.

How do I remove an RTBH route automatically?

Use a timer-based withdrawal, because once traffic is dropped upstream your flow data can't show whether the attack has ended. Withdraw after a fixed period, let the detector re-trigger if needed, and increase the duration on repeated triggers.

Is RTBH enough to protect a customer from DDoS?

No. RTBH protects your network and other customers by sacrificing availability of the attacked IP. For keeping the target online, consider FlowSpec filtering or a scrubbing service.

Test RTBH automation with a 15-day free NixMon trial. No credit card.Learn more