07-17-2008 02:39 AM - edited 03-06-2019 12:15 AM
can anyone pls explain the following regular expression examples, what the exact state? i don't check it...
ip as-path access-list 1 permit ^(8245_).*
ip as-path access-list 1 permit ^(13024_)*$
ip as-path access-list 1 permit ^(20605 *)+(28880 *|30820 *|29330 *)*$
ip as-path access-list 10 permit ^([0-9])+_([0-9])+$
Solved! Go to Solution.
07-17-2008 04:18 AM
Hi Marwan,
With regular expressions the Parentheses "( )" are used to nest characters for matching, it doesn't reflect confederation directly, to use it to match a confederation we must use "\" (escape character) which is used if an operator is inside the AS-Path (mainly used in the case of confederation) to remove its special meaning ex: AS-Path "(213 217) 765 312" to match on AS 213 we use the regular expression "^\(213_" in order not to be understood as an operator, or also "^\(213 217\)".
BR,
Mohammed Mahmoud.
07-17-2008 04:29 AM
Common Regular Expressions for AS Path Filters Regular Expression Routes Targeted
^$ Routes originating from this AS.
^2_ All routes from a directly connected neighbor in AS 2.
^2$ Routes originated by a neighbor in AS 2.
_3_ Routes containing AS 3.
{1 2} Aggregate route using the as-set option. Routes from AS 1 and AS 2 form the aggregate.
(65530) Confederation peer. The peer is in AS 65530
dear mohamed thanks for the reply
this info from Cisco® BGP-4 Command and Configuration Handbook
i think what u have said right
about the \
if i want to match the $ itself i can use
\$
thanks
07-17-2008 02:45 AM
^ mean strat with
$ mean end so that mean next hop last AS
. mean one match
* any matching
+ 0 or more occurance from the prevouse chrectors
_ mean space for example if u have ASs like
10 200 15 20
_15_ match the 15
_20$ match last AS 20
_20*
match 20 and 200
good luck
if helpful Rate
07-17-2008 03:54 AM
thx for explanation, but I'm still a little confused by the last one because of the brackets, may you can explain this one?
ip as-path access-list 10 permit ^([0-9])+_([0-9])+$
07-17-2008 04:05 AM
Hi,
"^" means the beginning of a line and "$" means the end of a line.
"[ ]" means any character listed between the brackets - can be written in 2 formats; [1234] or [1-4] -> means 1 or 2 or 3 or 4 - if contiguous like this example use the "-"
"+" means one or more instances of the character or pattern (at least once) - written after the required character(s).
Grabbing all these together, thus "^([0-9])+_([0-9])+$" means, an AS-Path list consisting of any 2 ASN, each has at least one digit from 0 to 9.
Please check this out "Cisco Regular Expression Pattern Matching Characters":
BR,
Mohammed Mahmoud.
07-17-2008 04:09 AM
the brackets relate to what is called confideration bgp peer
which is ASs within an AS it is used with big bgp domains
so
it match two peers within the confideration
first AS first one begin with anumber between 0-to-9 and the + Matches one or more sequences of the pattern
the next AS the same between 0-9 and the + Matches one or more sequences of the pattern
if helpful rate
07-17-2008 04:18 AM
Hi Marwan,
With regular expressions the Parentheses "( )" are used to nest characters for matching, it doesn't reflect confederation directly, to use it to match a confederation we must use "\" (escape character) which is used if an operator is inside the AS-Path (mainly used in the case of confederation) to remove its special meaning ex: AS-Path "(213 217) 765 312" to match on AS 213 we use the regular expression "^\(213_" in order not to be understood as an operator, or also "^\(213 217\)".
BR,
Mohammed Mahmoud.
07-17-2008 04:29 AM
Common Regular Expressions for AS Path Filters Regular Expression Routes Targeted
^$ Routes originating from this AS.
^2_ All routes from a directly connected neighbor in AS 2.
^2$ Routes originated by a neighbor in AS 2.
_3_ Routes containing AS 3.
{1 2} Aggregate route using the as-set option. Routes from AS 1 and AS 2 form the aggregate.
(65530) Confederation peer. The peer is in AS 65530
dear mohamed thanks for the reply
this info from Cisco® BGP-4 Command and Configuration Handbook
i think what u have said right
about the \
if i want to match the $ itself i can use
\$
thanks
07-17-2008 04:37 AM
Hi Marwan,
You are very welcomed, yes we use the "/" as an escape character in order to be able to match one of the operator characters, like you said for example the "$".
BR,
Mohammed Mahmoud.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide