Home » Routing » BGP » Understanding BGP communities

Understanding BGP communities

What are BGP communities?

The BGP community attribute is a numerical value that can be assigned to a specific prefix and advertised to other neighbors. When the neighbor receives the prefix it will examine the community value and take proper action whether it is filtering or modifying other attributes.

By default the community attribute is removed from the update before being sent to the neighbor. To allow community values to be sent to a specific neighbor the command neighbor x.x.x.x send-community must be applied.

BGP has default 4 well known communities that can be used to mark prefixes; listed as follows:

  • Internet: advertise these routes to all neighbors.
  • Local-as: prevent sending routes outside the local As within the confederation.
  • No-Advertise: do not advertise this route to any peer, internal or external.
  • No-Export: do not advertise this route to external BGP peers.

Why using BGP communities?

Communities can be used to mark a set of prefixes that share a common property. Upstream providers can use these marks to apply a common routing policy such as filtering or assigning a specific local preference.

As a service provider you can make an agreement with your customers on a specific policy to be applied to their prefixes using communities; this gives your customers the freedom to change the policy of a prefix just by changing the community attribute value with no support from your side.

Consult this link for an example of Using BGP community values to control routing policy.

How to set community attribute values?

  • Network command: the optional route-map at the end of the network command can be used to set the community of the advertised prefix.
  • Aggregate address: the Attribute-map option can be used to set the attributes of the aggregate route including the community value.
  • Neighbor command: a route-map can be used to set the community of specific prefixes received from or sent to the neighbor.
  • Redistribution: you can set the community attribute of the redistributed prefixes using the route-map option of the redistribute command.

How to match community attribute values?

  • A standard or expanded IP community list must be configured specifying the values to be matched.
  • Use the match statement in a route map to match the values specified in the IP community list.
  • The route-map can be used to apply routing policies by setting other attributes or filtering the prefix based on the matched community value.

Here is a simple example:

R1 is directly connected to R2 with an IBGP session between them; the example will show you how to use communities to manipulate BGP attributes:

Configuration of R1:

R1(config)#ip bgp-community new-format

R1(config)#route-map SETCOM
R1(config-route-map)#set community 1:10

R1(config)#router bgp 12
R1(config-router)#neighbor 192.168.12.2 remote-as 12
R1(config-router)#neighbor 192.168.12.2 send-community

!-- The network 150.1.1.0 is advertised with community 1:10
R1(config-router)#network 150.1.1.0 mask 255.255.255.0 route-map SETCOM

!-- R1's BGP table
R1(config)#do sh ip bgp 150.1.1.0
BGP routing table entry for 150.1.1.0/24, version 2
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Not advertised to any peer
  Local
    0.0.0.0 from 0.0.0.0 (192.168.127.1)
      Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best
      Community: 1:10

Configuration of R2:

R2(config)#router bgp 12
R2(config-router)#nei 192.168.12.1 remot 12

!-- Before applying any policies
R2#sh ip bgp 150.1.1.0
BGP routing table entry for 150.1.1.0/24, version 2
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Not advertised to any peer
  Local
    192.168.12.1 from 192.168.12.1 (192.168.127.1)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      Community: 1:10

!-- Match the community using a standard community-list
R2(config)#ip community-list 1 permit 1:10
R2(config)#route-map COM
R2(config-route-map)#match community 1
R2(config-route-map)#set metric 100

R2(config)#router bgp 12
R2(config-router)#nei 192.168.12.1 route-map COM in

!-- After applying the policy the metric changed to 100
R2#sh ip bgp 150.1.1.0/24
BGP routing table entry for 150.1.1.0/24, version 3
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x800
  Not advertised to any peer
  Local
    192.168.12.1 from 192.168.12.1 (192.168.127.1)
      Origin IGP, metric 100, localpref 100, valid, internal, best
      Community: 1:10

Hope I have been informative; more practical examples on using BGP communities is coming in later posts.

Update:

As you can see in the comments below, Ivan has spotted an myth about the internet community in his post mysteries of the internet community; please check out for details.

11 comments

  1. Please stop spreading the “Internet” community myth :) See my blog post for details.

  2. Thanks Ivan for the correction, that’s why it is important to have masters like you :)

  3. good post. thanks

  4. Thanks !!, It;s great example.

  5. Finally, a good and straight forward explanation about BGP communities.

    Thanks, needed that refresher.

    Victor. CCNP

  6. Very good and detailed information….

    Thanks!

  7. to the point detail… nice networks onlie

  8. To the point detail. Nice Network online

  9. Hello,

    It is indeed a well written explanation about BGP communities. There is however something i still don’t get if i may.
    Let’s consider that this command “set comunity X:Y” is issued. Can anyone explain to me to what X and Y values are refering to and how to decide which value should they take.

    Thanks in advance

  10. What if a router receives an update with community while the router doesnt have any rule for that community. To be specific if router doesnt have any route map at all.

    Whether the router will take the update and process it or will just discard it?

  11. A minor detail: In R2 lwas not issued ip bgp-community new-format as well

Leave a Reply

Your email address will not be published. Required fields are marked *