The if-match community-filter command sets a filtering rule that is based on the community filter.
The undo if-match community-filter command cancels the configuration.
By default, no filtering rule based on the community filter is set.
Parameter | Description | Value |
---|---|---|
basIndex |
Specifies the number of the basic community filter. |
The value is an integer ranging from 1 to 99. |
whole-match |
Indicates complete matching. That is, all the communities in the command must be matched. Complete matching is valid only for the basic community filter. |
- |
AdvIndex |
Specifies the number of the advanced community filter. |
The value is an integer ranging from 100 to 199. |
sort-match |
Indicates sort matching. That is, all the communities in the command must be matched in sequence. Sort matching is valid only for the advanced community filter. |
- |
cfName |
Specifies the name of the community filter. |
The value is a string of 1 to 51 case-sensitive characters, spaces not supported. The string cannot be all numbers. When double quotation marks are used around the string, spaces are allowed in the string. |
Usage Scenario
The community attribute is a proprietary attribute of BGP. The if-match community-filter command is applicable mainly to BGP routes. The ip community-filter command must be used to define a community filter so that the filtering rule based on this community filter can take effect. For example:
Prerequisites
A community filter has been configured using the ip community-filter command.
A route-policy has been configured using the route-policy command.Configuration Impact
When you filter routes based on the community attributes, the routes that match the filtering rule are permitted and the routes that do not match the filtering rule are denied.
Precautions
The community filters can be configured in the if-match community-filter command. The relationship between these community filters is OR. Specifically, if a route matches one of these community filters, it matches the matching rules of the command. If the if-match community-filter command is run more than once, the relationship between its configurations is OR.
The parameter whole-match is valid only for its front community filter. If multiple community filters are specified in the if-match community-filter command and packets are required to completely match each filter, you need to specify the parameter whole-match behind each community filter. The parameter sort-match is valid only for its front community filter. If multiple community filters are specified in the if-match community-filter command and packets are required to wholly match the regular expansion in the filter in sequence, you need to specify the parameter sort-match behind each community filter. The name of a community filter cannot be all numbers.<HUAWEI> system-view [~HUAWEI] ip community-filter 1 permit [*HUAWEI] ip community-filter 2 permit [*HUAWEI] route-policy test permit node 11 [*HUAWEI-route-policy] if-match community-filter 1 whole-match 2 whole-match
<HUAWEI> system-view [~HUAWEI] ip community-filter 101 permit ^10 [*HUAWEI] route-policy test permit node 13 [*HUAWEI-route-policy] if-match community-filter 101 sort-match
<HUAWEI> system-view [~HUAWEI] ip community-filter basic aa permit [*HUAWEI] route-policy test permit node 12 [*HUAWEI-route-policy] if-match community-filter aa
<HUAWEI> system-view [~HUAWEI] ip community-filter 1 permit 100:200 [*HUAWEI] route-policy test permit node 10 [*HUAWEI-route-policy] if-match community-filter 1