BGP Communities- An introduction and Configuration example

BGP Communities are one of the most important topics in BGP as per the interview point of view. BGP communities has a significant role whenever you are going to design the BGP based network.

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.
Fig 1.1- BGP Communities

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.