Documentation
Name
bgp router peer filter add-rule match - defines the predicate of a rule in a filter
Synopsis
match <predicate>
Arguments
- predicate
- the predicate associated with the rule
Description
This command defines the predicate of the current rule. The predicate is provided as the command argument. The predicate is a logical combination of atomic predicates. Each atomic predicate can be used to test a single attribute of a route.
The following atomic predicates are supported:
Predicate expression | Description |
---|---|
any | all routes |
community is C | routes that contain community C |
next-hop is N | routes whose next-hop is N |
next-hop in P | routes whose next-hop is in P |
prefix is P | routes whose prefix is P |
prefix in P | routes whose prefix is in P |
path R | routes whose AS-path matches regexp R |
The following example defines a filter rule that discards routes originated by AS11537 (11537 is the latest ASN in the AS-path):
add-rule
match 'path "11537$"'
action deny
When providing the predicate expression, care must be taken to correctly enclose it with quotes. The C-BGP parser relies on a simple tokenization mechanism that splits a line into tokens separated by spaces. There is an exception for spaces that appear in quoted text. If you want to provide an expression that contains multiple words, you need to quote it (using " or '). Actually, all the predicate expressions except "any" (which is a single word) need to be quoted.
Sometimes, quoting is also required by the atomic predicate. An example is "path R" where R is a regular expression that needs to be quoted if it includes spaces. In this case, two levels of quoting are required. One option is to write "path \"...reg-exp...\"". Another possibility is to use different quotes, e.g. 'path "...reg-exp..."' as shown in the above example.
Atomic predicates can be combined using logic operators to form more complex predicates. The supported operators are as follows:
Symbol | Operator |
---|---|
| | or |
& | and |
! | not |
The following example defines a filter rule that prepends twice the AS-path of routes with community 1 or community 2:
add-rule
match "community is 1 | community is 2"
action "as-path prepend 2"