BGP Communities: Well-Known Values and Cisco Configuration - 夜莺博客

BGP Communities: Well-Known Values and Cisco Configuration

BGP communities are the tagging system that makes policy scalable: instead of matching hundreds of individual prefixes with ACLs or regexes, you attach a community to a route and let neighbors (or your own route-maps) act on the tag. Some communities are well-known with standardized meaning; most are operator-defined conventions like "set local-pref 110 toward this upstream". This guide covers well-known values, enabling community exchange, and the Cisco IOS route-map workflow for setting and matching communities.

Well-Known Community Values

Name Value Meaning
internet 0x00000000 advertise anywhere (default, implicit)
no-export 0xFFFFFF01 / 65535:65281 do not advertise to any eBGP peer (iBGP within the AS is fine)
no-advertise 0xFFFFFF02 / 65535:65282 do not advertise to ANY peer (install locally only)
local-AS (no-export-subconfed) 0xFFFFFF03 / 65535:65283 do not advertise outside the local confederation sub-AS
blackhole 65535:666 (RFC 7999) signal the peer to null-route the prefix (RTBH)
graceful-shutdown 65535:0 (RFC 8326) signal peers to set local-pref 0 for graceful maintenance

A standard community is a 32-bit value, conventionally written AS:value (e.g. 65001:100). Extended communities (64-bit, RFC 4360) add structure - Route Targets (rt:) drive MPLS L3VPN import/export, and Site of Origin (soo:) prevents loops in multi-homed VPN sites.

Step 1: Enable Community Exchange

Cisco IOS does not send communities to neighbors unless told to:

router bgp 65001
 neighbor 203.0.113.2 send-community
 neighbor 10.10.10.2 send-community both   ! standard + extended

Without send-community, tags silently never leave the router - the most common "my communities do nothing" cause.

Step 2: Set Communities with a Route-Map

ip prefix-list LAB-PREFIXES permit 10.10.0.0/16 le 24

route-map TAG-INTERNAL permit 10
 match ip address prefix-list LAB-PREFIXES
 set community 65001:100 no-export additive
!
router bgp 65001
 neighbor 10.10.10.2 route-map TAG-INTERNAL out

additive appends to any existing communities; without it, the set replaces them all. The well-known names (no-export, no-advertise) are accepted directly in set community.

Step 3: Match Communities for Filtering or Policy

ip community-list standard CUST-100 permit 65001:100
ip community-list expanded CUST-1XX permit ^65001:1[0-9][0-9]$

route-map FILTER-BY-COMMUNITY deny 10
 match community CUST-100
route-map FILTER-BY-COMMUNITY permit 20
!
router bgp 65001
 neighbor 203.0.113.2 route-map FILTER-BY-COMMUNITY in

Standard community lists match exact values; expanded lists use regex over the community string. Route-maps then act on matches - typical actions are set local-preference, set as-path prepend, or deny (filtering).

Real-World Conventions

  • Traffic engineering with upstreams: <ISP-AS>:90/100/110 tells the ISP to set local-pref 90 (less preferred), 100 (normal) or 110 (preferred); <ISP-AS>:302/303 asks for 2x/3x prepend.
  • RTBH: tag an attacked /32 with the blackhole community (e.g. 65535:666); the upstream null-routes it at the edge.
  • Regional scoping: e.g. 65000:1000 = US-only, 65000:2000 = EU-only, combined with no-export so the route never leaves the region.
  • MPLS L3VPN: VRFs import/export via route-target extended communities, and SoO prevents a site's routes from being reflected back.

Communities interact with the rest of BGP policy machinery: route-maps and prefix-lists for matching (see our prefix-list and route-map guide), the best-path algorithm that applies local-pref early in the decision, and route dampening (penalty and reuse limits) for flapping-prefix hygiene.

原文链接:https://awjunaid.com/cisco/how-to-configure-bgp-communities-on-cisco-routers-complete-guide-with-examples