The BGP AS path attribute includes a list of autonomous systems that routing information has passed through to get to a specified router and an indicator of the origin of this route. Each autonomous system through which a route passes prepends its AS number to the beginning of the AS path. The AS path is used to prevent routing loops in BGP.
This routing information can be used to prefer one path to a destination network over another. The route-map supports the configuration of AS path preference when importing and exporting routes. The matching of an AS path packet attribute is configured in a route-map using the match as-path command.
The match as-path command supports the following regular expressions:
Character | Description | Example
|
---|---|---|
^ | Start of string. | ^200 matches any string starting with “200”. |
$ | End of string. | 200$ matches any string ending with “200”. |
. | Matches any character. | 2.0 match “200”, “210”, “220” |
* | Matches the preceding element zero or more times. | 22* matches “2”,” 22”, “222” |
.* | Matches any character any number of times. | This is a match all. |
[ ] | Matches a single character inside the brackets. | [d] matches the character “d”. |
[-] | Matches a range. | [0-9] matches any number from 0 to 9. |
( ) | Specifies a subexpression. | (200:500) is treated as a single entity. |
[^] | Matches any single character not specified in the brackets. | [^er] matches all characters except for “e” and “r”. |
? | Matches the preceding exactly. | 200? matches “200” only. |
+ | Matches the preceding element one or more times. | 200? matches “200”, “200200”, “200200200”. |
| | Matches either the expression before or the expression after the operator (the choice operator). | 100 | 250 matches either “100” or “250” |
Note
Regular expressions are also supported by the BGP community and extended community attributes.This example shows how to match a packet AS path attribute that starts with AS number 20313 and with the next AS number ending with 13:
System(su)->configure System(su-config)->route-map bgp bgprm1 permit System(su-config-route-map-bgp)->match as-path ^20313.*13$ System(su-config-route-map-bgp)->show route-map bgprm1 route-map bgp bgprm1 permit 10 match afi ipv4 match safi unicast match as-path "^20313_*13$" System(su-config-route-map-bgp)->
See Route-Map Manager Configuration for BGP route-map configuration details.