BGP communities: a practical guide to traffic engineering
The levers your transit provider gives you, what each one actually does, and how to use them without breaking things.
Almost every transit provider publishes a community set. Almost every customer uses two of them: the one that blackholes an address, and the one that stops an announcement going to a competitor. The rest sit unused, which is a shame, because they are the difference between routing you control and routing that happens to you.
The three community formats
You will meet all three in production.
- Standard communities (RFC 1997) are 32 bits, conventionally written
ASN:value. Fine while your ASN is 16-bit; cramped otherwise. - Extended communities (RFC 4360) are 64 bits and mostly used for VPN route targets rather than transit signalling.
- Large communities (RFC 8092) are 96 bits, written as
ASN:function:parameter. This is the format to prefer: it holds a 32-bit ASN and still leaves room for a function and a target.
A modern provider publishes large communities. If yours only offers standard communities with a 4-byte ASN, ask why.
Category 1: local preference
These tell the provider how much it should prefer your announcement relative to its other sources. The usual scheme is a set of communities mapping to specific localpref values.
# Lower our localpref inside the provider so a backup path wins
route-map TO-TRANSIT permit 10
set large-community 64535:100:80 additive
The common use is failover between your own sites: announce from both, lower the localpref on the one you want as backup. This is far cleaner than prepending because it is deterministic - you know exactly what the provider will do.
Category 2: selective advertisement
These control which of the provider's peers and upstreams see your prefix. Two forms:
- Do not announce to ASN X. Useful when you have a direct session with X and want that path preferred, or when a specific network is causing you grief.
- Announce only to ASN X or only to region Y. Useful for regional anycast, where you want a prefix visible from Europe but not from Asia.
The failure mode to watch for: suppress too broadly and a prefix becomes unreachable from a region you forgot about. Change one community at a time and verify from a looking glass in each region before moving on.
Category 3: regional prepending
Rather than prepending globally and hoping, a per-region prepend community asks the provider to prepend your AS a specified number of times, but only when announcing to peers in a given region.
# Prepend twice, but only towards North America
set large-community 64535:102:2840 additive
This is the right tool for shifting inbound traffic between two continents when you have capacity in both. Two prepends is usually enough to move traffic; five is a sign you should be solving the problem a different way.
Category 4: blackholing
RFC 7999 standardised 65535:666 as the well-known blackhole community. Announce a /32 or /128 carrying it and the provider drops all traffic to that address at their edge.
ip route 203.0.113.42/32 null0
route-map BLACKHOLE permit 10
match ip address prefix-list VICTIM
set community 65535:666 additive
Two refinements worth having:
- Regional blackholing. Drop the traffic only where the attack is sourced, and stay reachable everywhere else. NTT popularised this as selective blackholing and it is now widely available.
- Automatic expiry. A blackhole is a self-inflicted outage for that address. Withdraw it automatically after a fixed period so it does not outlive the attack by three weeks.
Category 5: informational communities
Communities the provider adds on ingress, telling you where a route entered their network and what kind of relationship it came from. These do nothing to routing but everything for diagnosis: they let you answer "did this prefix reach us via a peer in Frankfurt or an upstream in Ashburn?" from the routing table alone.
Putting it together safely
- Document intent alongside the config. A bare community in a route-map is unreadable in six months. Comment what it is for and when it should be removed.
- Change one thing at a time and verify from multiple looking glasses. Regional effects are invisible from your own edge.
- Set expiry on anything temporary. Blackholes and prepends added during an incident should not still be there next quarter.
- Keep policy in version control. Communities are configuration; they should be reviewable and revertible like any other.
- Verify propagation, not just acceptance. A community your provider accepts but does not act on is worse than none, because you will believe it worked.
Communities are the closest thing BGP has to an API. A provider that publishes a complete set and acts on it within seconds is handing you control; one that asks you to raise a ticket for a localpref change is not.