Community Lists
A community is a logical group of prefixes that share some common attribute. Community members can be on different networks and in different ASs. BGP allows you to define the community to which a prefix belongs. A prefix can belong to more than one community. The community attribute lists the communities to which a prefix belongs.
You can use communities to simplify routing policies by configuring the routing information that a BGP speaker will accept, prefer, or distribute to other neighbors according to community membership. When a route is learned, advertised, or redistributed, a BGP speaker can set, append, or modify the community of a route. When routes are aggregated, the resulting BGP update contains a community attribute that contains all communities from all of the aggregated routes (if the aggregate is an AS-set aggregate).
Several well-known communities are predefined. Table 1-2 describes how a BGP speaker handles a route based on the setting of its community attribute.
Table 1-2 Action based on well-known community membership
In addition to the well-known communities, you can define local-use communities, also known as private communities or general communities. These communities serve as a convenient way to categorize groups of routes to facilitate the use of routing policies. The community attribute consists of four octets, but it is common practice to designate communities in the AA:NN format. The autonomous system number (AA) comprises the higher two octets, and the community number (NN) comprises the lower two octets. Both are expressed as decimal numbers. For example, if a prefix in AS 23 belongs to community 411, the attribute could be expressed as 23:411. Use the ip bgp-community new-format command to specify that the show commands display communities in this format. You can also use a regular expression to specify the community attribute.
Use the set community command in route maps to configure the community attributes. You can add one or more communities to the attribute, or use the list keyword to add a list of communities to the attribute. By default, the community attribute is not sent to BGP peers. To send the community attribute to a neighbor, use the neighbor send community command.
A community list is a sequential collection of permit and deny conditions. Each condition describes the community number to be matched. If you issued the ip bgp-community new-format command, the community number is in AA:NN format; otherwise it is in decimal format (the hexadecimal octets converted to decimal).
The router tests the community attribute of a route against each condition in a community list. The first match determines whether the router accepts (the route is permitted) or rejects (the route is denied) a route having the specified community. Because the router stops testing conditions after the first match, the order of the conditions is critical. If no conditions match, the router rejects the route.
Consider the network structure shown in Figure 1-5.
![]()
Suppose you want router Albany to set metrics for routes that it forwards to router Boston based on the communities to which the routes belong. You can create community lists and filter the routes with a route map that matches on the community list. To configure router Albany:
host1(config)#router bgp 293host1(config-router)#neighbor 10.5.5.2 remote-as 32host1(config-router)#neighbor 10.2.2.1 remote-as 451host1(config-router)#neighbor 10.2.2.4 remote-as 17host1(config-router)#neighbor 10.2.2.4 route-map commtrc outhost1(config-router)#exithost1(config)#route-map commtrc permit 1host1(config-route-map)#match community 1host1(config-route-map)#set metric 20host1(config-route-map)#exithost1(config)#route-map commtrc permit 2host1(config-route-map)#match community 2host1(config-route-map)#set metric 75host1(config-route-map)#exithost1(config)#route-map commtrc permit 3host1(config-route-map)#match community 3host1(config-route-map)#set metric 85host1(config-route-map)#exithost1(config)#ip community-list 1 permit 25host1(config)#ip community-list 2 permit 62host1(config)#ip community-list 3 permit internetCommunity list 1 comprises routes with a community of 25; their metric is set to 20. Community list 2 comprises routes with a community of 62; their metric is set to 75. Community 3 catches all remaining routes by matching the internet community; their metric is set to 85.
ip bgp-community new-format
- Use to specify that communities must be displayed in AA:NN format, where AA is a number that identifies the autonomous system and NN is a number that identifies the community within the autonomous system.
- Example
host1(config)#ip bgp-community new-formatip community-list
- Use to create a community list for BGP and control access to it. The list name can be up to 32 characters long.
- A route can belong to any number of communities, so a community list can have many entries comprising many communities.
- You can specify one or more community values when you create a community list. A clause in a route map that includes a list having more than one value matches only a route having all of the values; that is, the multiple values are logical ANDed.
- You can specify community values with a number or a regular expression.
- Example
host1(config)#ip community-list 1 permit 100:2 100:3 100:4host1(config)#route-map marengo permit 10host1(config-route-map)#match community 1A route matches this community list only if it belongs to at least all three communities in community list 1: communities 100:2, 100:3, and 100:4.
neighbor send-community
- Use to specify that a community attribute should be sent to a BGP neighbor.
- If you specify a BGP peer group by using the peer-group-name argument, all the members of the peer group will inherit the characteristic configured with this command.
- Use the no version to specify that common attributes should not be sent to a BGP neighbor.
set community
- Use to set the community attribute in BGP updates.
- You can specify a community list number in the range 1-4294967295, or in the new community format of AA:NN, or one of the following well-known communities:
- local-as - prevents advertisement outside of the local AS
- no-advertise - prevents advertisement to any peer
- no-export - prevents advertisement beyond the BGP confederation boundary
- Alternatively, you can use the list keyword to specify the name of a community list that you previously created with the ip community-list command.
- Supported for inbound, outbound, and redistribution route maps.
- Example
host1(config)#route-map 1host1(config-route-map)#set community no-advertise
- Use the none keyword to remove the community attribute from a route.
- Use the no version to delete the entry.
Extended Community Lists
The system supports the BGP extended community attribute defined in the Internet draft, BGP Extended Communities Attribute - draft-ietf-idr-bgp-ext-communities-05.txt (November 2002 expiration). This attribute enables the definition of a new type of IP extended community and extended community list unrelated to the community list that uses regular expressions.
Note: IETF drafts are valid for only 6 months from the date of issuance. They must be considered as works in progress. Please refer to the IETF Web site at http://www.ietf.org for the latest drafts.![]()
BGP speakers can use the extended community attribute to control routes much like they use the community attribute to determine routes they accept, reject, or redistribute. A BGP speaker can append the extended community attribute to a route that does not have the attribute before advertising the route. For routes that do have the attribute, BGP can modify the attribute.
ip extcommunity-list
- Use to create an extended community list for BGP and control access to it.
- A route can belong to any number of communities, so an extended community list can have many entries comprising many communities.
- You can specify one or more community values when you create an extended community list. A clause in a route map that includes a list having more than one value matches only a route having all of the values; that is, the multiple values are logical ANDed.
- Use the rt keyword to specify a route target community, which consists of one or more routers that can receive a set of routes advertised by BGP that carry the extended community attribute.
- Use the soo keyword to specify a site-of-origin community, which consists of one or more routers that inject into BGP a set of routes that carry the extended community attribute.
- Example
host1(config)#ip extcommunity-list boston1 permit rt 100:2 rt 100:3 rt 100:4host1(config)#route-map marengo permit 10host1(config-route-map)#match extcommunity boston1A route matches this community list only if it belongs to at least all three communities in extended community list boston1: communities 100:2, 100:3, and 100:4.
- Use the no version to remove a single extended community list entry if permit or deny and a path-expression are specified. Otherwise, the entire community list is removed.
match extcommunity
- Use to match an extended community list in a route map.
- You can specify one or more extended community list names in a match clause. If you specify more than one extended community list, the lists are logically ORed.
- Example
host1(config-route-map)#match extcommunity topeka10
- Use the no version to remove the match clause from a route map or a specified value from the match clause.
set extcommunity
- Use to set the extended community attributes in a route map for BGP updates.
- Use the rt keyword to specify a route target community, which consists of one or more routers that can receive a set of routes advertised by BGP that carry the extended community attribute.
- Use the soo keyword to specify a site-of-origin community, which consists of one or more routers that inject into BGP a set of routes that carry the extended community attribute.
- You can specify both a route target community and a site-of-origin community at the same time in a set clause without overwriting each other.
- Example
host1(config)#route-map 1host1(config-route-map)#set extcommunity rt 10.10.10.2:325show ip extcommunity-list
- Use to display information about a specific extended community list or all extended community lists.
- Example
host1#show ip extcommunity-listIP Extended Community List dresden1:permit soo 10.10.10.10:15IP Extended Community List bonn:deny rt 12:12