AS_Path List Overview
Introduction
An AS_Path list is a collection of filters that are used to filter BGP routes based on AS_Path attributes contained in BGP routes. AS_Path attributes record the number of each AS that BGP routes pass through from the source to the destination in distance-vector order.
If two AS_Paths both can enable communications, the AS_Path with a smaller ASN is preferred because it uses a shorter path.
AS_Path attributes are private attributes of BGP and AS_Path filters take effect only on BGP routes.
Match Rules
An AS_Path attribute can be regarded as a string containing spaces and is used to match routes through a regular expression.
In Figure 1, the ASN of ER-A is 100. If a BGP route from the peer passes through ER-A, the ASN 100 of ER-A is automatically added to the left of AS_Path.
A regular expression is a string that describes a characteristic and verifies whether another string conforms to this characteristic. An AS_Path filter defines an AS_Path regular expression to match AS_Path attributes of BGP routes for filtering BGP routes.
- If a route matches an AS_Path filter with Action set to Allow, the route is allowed. If the AS_Path filter has Action set to Deny, the route is denied.
- If a route does not match any AS_Path filter in an AS_Path list, the route is denied.
An AS_Path list filters routes by sequential match, unique match, or deny by default.
- Sequential match: An AS_Path filter with a smaller number is matched first. AS_Path filters in an AS_Path list can be sorted by sequence number in different orders, leading to different filtering results.
- Unique match: If a route matches an AS_Path filter, it no longer tries to match other AS_Path filters.
- Deny by default: By default, routes that do not match any AS_Path filter in an AS_Path list are denied. If an AS_Path list has one or more deny filters, you need to create an AS_Path filter to allow all other routes.
AS_Path Regular Expressions
An AS_Path filter is essentially a regular expression. The content of a regular expression is complex. The following describes the AS_Path filter.
An AS_Path filter uses a regular expression to define matching rules. A regular expression consists of the following parts:
- Metacharacter: defines matching rules.
- General character: defines match objects.
Table 1 lists the metacharacters supported by BGP AS_Path regular expressions.
Metacharacter |
Description |
Example |
---|---|---|
. |
Matches AS_Paths with any single character except "\n", including spaces. |
.* matches any AS_Path or route.
NOTE:
If an AS_Path list has one or more deny filters, you need to create an AS_Path filter to allow all other routes. |
* |
Matches AS_Paths with 0 or more sequences of the character before the asterisk "*". |
See the preceding example. |
+ |
Matches AS_Paths with 1 or more sequences of the character before the plus sign "+". |
65+ matches AS_Paths that begin with 6 and include one 5 or consecutive 5.
|
| |
Matches any AS_Path with characters on either side of the vertical bar "|". |
100|65002|65003 matches 100, 65002, or 65003.
AS_Path examples that 100|65002|65003 matches:
|
^ |
Matches AS_Paths beginning with the characters that follow the caret "^". |
^65 matches AS_Paths beginning with 65.
|
$ |
Matches AS_Paths ending with the characters before the dollar sign "$". |
65$ matches AS_Paths ending with 65.
NOTE:
^$ matches null character strings (null AS_Path) and can be used to match the locally originated routes. |
( ) |
Defines a subexpression. Both the expression and the subexpression must match. |
100(200)+ matches AS_Paths that begin with 100 and include one 200 or consecutive 200.
AS_Path examples that 100(200)+ matches:
|
[ ] |
Matches AS_Paths with any character in the brackets "[ ]". |
NOTE:
The characters in the brackets "[ ]" can only be numbers 0 to 9. To match AS_Paths within the range of 735 to 907, use (73[5-9]|7[4-9][0-9]|8[0-9][0-9]|90[0-7]). |
[^ ] |
Matches AS_Paths without any character within the range specified in the brackets "[ ]". |
|
_ |
Matches AS_Paths with a sign, such as a comma ",", left brace "{", right brace "}", left parenthesis "(", right parenthesis ")", or space. An underscore "_" can be used at the beginning of a regular expression with the same function as the caret "^" or at the end of a regular expression with the same function as the dollar sign "$". |
|
\ |
Indicates an escape character. |
A backslash "\" is used to disable special functions of signs in regular expressions, such as the left parenthesis "(" and right parenthesis ")" in an AS_Confed_Sequence, the left bracket "[" and right bracket "]" in an AS_Confed_Set, and the left brace "{" and right brace "}" in an AS_Set.
|
Notes and Constraints
- By default, an account can have up to five AS_Path lists.
- By default, each AS_Path list can have up to 100 AS_Path filters.
- Changing an AS_Path list will also change the associated routes and traffic routing. To reduce the impact on network performance, an AS_Path list can only be changed once within 40 seconds.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot