To use this command, you must be in a user group associated with a task group that includes appropriate task IDs. If the user group assignment is preventing you from using a command, contact your AAA administrator for assistance.
Use the community matches-every command as a conditional expression within an if statement to match every element of a community set.
For a list of all conditional expressions available within an if statement, see the if command.
A simple condition using the matches-every operator evaluates as true if every specification in the named set or inline set specified matches at least one community value in the route. If any community specification in the named or inline set is not matched, then the operation evaluates to false.
Matching of a community in the route to a specification in a named or an inline set is intuitive. If the community-specification in a set is the familiar colon-separated decimal 16-bit numbers specification, or one of the well-known communities, the community matches the specification if the specification denotes the same 32-bit number as that in the route. If the community specification uses a wildcard, then the community in the route matches if it is one of the many communities denoted by the wildcard specification. In inline sets, community specifications may be parameterized, in which case the relevant matching is done when the value of the parameter has been supplied.
Communities may also be matched using range and regular expression operators. Range specifications are entered as follows: [ low-value .. high-value ]. Either or both colon-separated halves of a community value may contain a range. The following are valid range specifications:
Therefore, a matches-every operation with two community range specifications means that a community must be present in the route that corresponds to each range. For example, in the following statement:
if community matches-every (10:[100..200],20:[100..200]) then
the statement evaluates as true if one or more communities in the route lie in the range 10:[100.200] and one or more communities in the route lie in the range 20:[100..200].
In addition, the private-as keyword may be used to specify the range from 64512 to 65534.
Regular expressions are specified as the ios-regex keyword followed by a valid single-quoted regular expression string. Community values from the route are matched one at a time against the match specifications. Therefore, regex match specifications are expected to represent one individual community value and not a sequence of community values.
In the following example, the route policy named community-matches-every-example sets the local-preference value to 100 for all routes that have all three communities in the my-community-set community set. Routes that do not have all three communities but have a community that matches the first regular expression match have the local-preference value set to 200. Finally, any remaining routes that match the last regular expression have the local-preference values set to 300.
RP/0/RSP0/CPU0:router(config)# community-set my-community-set
RP/0/RSP0/CPU0:router(config)# route-policy community-matches-every-example
RP/0/RSP0/CPU0:router(config-rpl)# if community matches-every my-community-set then
RP/0/RSP0/CPU0:router(config-rpl-if)# set local-preference 100
RP/0/RSP0/CPU0:router(config-rp-elseif)# elseif community matches-every (ios-regex ’_10:[0-9]0_’) then
RP/0/RSP0/CPU0:router(config-rpl-elseif)# set local-preference 200
RP/0/RSP0/CPU0:router(config-rpl-elseif)# elseif community matches-every (ios-regex’_20:[0-9]0_’) then
RP/0/RSP0/CPU0:router(config-rpl-elseif)# set local-preference 300