match community

To match a Border Gateway Protocol (BGP) community, use the match community command. To remove the match community command from the configuration file and restore the system to its default condition where the software removes the BGP community list entry, use the no form of this command.

match community name [... name ] [ exact-match ]

no match community name [... name ] [ exact-match ]

Syntax Description

One or more community list names. The name can be any alphanumeric string up to 63 characters. You can configure a maximum of 32 community lists.
(Optional) Indicates that an exact match is required. All of the communities and only those communities specified must be present.

Command Default

No community list is matched by the route map.

Command Modes

Route-map configuration mode

Command History

This command was introduced.

Usage Guidelines

A route map can have several parts. Any route that does not match at least one match command that is related to a route-map command is ignored; that is, the route is not advertised for outbound route maps and is not accepted for inbound route maps. If you want to modify some particular data, you must configure a second route-map section with an explicit match specified.

Matching that is based on the community list number is one of the types of match commands applicable to BGP.


This example shows how to match two BGP communities:

switch(config)# route-map test2
switch(config-route-map)# match community bgpLow bgpHigh

This example shows that the routes that match community list 1 have the weight set to 200. Any route that has the standard community 109 only has the weight set to 200.

switch(config)# ip community-list standard bgpLow permit 109
switch(config)# route-map set_weight
switch(config-route-map)# match community bgpLow exact-match
switch(config-route-map)# set weight 200

This example shows the routes that match the community list 500. Any route that has expanded community 1 have the weight set to 150.

switch(config)# ip community-list expanded 500 permit [0-9]*
switch(config)# route-map MAP_NAME permit 10
switch(config-route-map)# match community 500
switch(config-route-map)# set weight 150

Related Commands

ip community-list
Creates a community list for BGP and controls access to it.
Defines the conditions for redistributing routes from one routing protocol into another.
set weight
Specifies the BGP weight for the routing table.