#

Friday, August 23, 2019

A Note on Regular Expressions Used in Cisco IOS

Regular expressions are commonly used to filter out show commands like show ip bgp and to identify a route in AS-Path Lists.

Character Meaning
 ^  start of a string  
$ end of a string
[] range of characters 
- used to specify range ( i.e. [0-9] )
( ) logical grouping
. any single character
* repeat previous character zero or more times
+ repeat previous character one or more times
? repeat previous character zero or one time
_ matches the space between AS numbers
\\ an escape character used for BGP confederations

Some commonly used examples:-

String Meaning
.* anything, all prefixes, will match everything
^$ match all prefixes learned from the local AS
^67_ match all prefixes learned from AS 67 
_67$ match all prefixes originated in AS 67
_67_ match all prefixes any instance of AS 67
^[0-9]+$ match all prefixesprefixes originated from directly connected ASes

Now let's see the above expressions applied in the following real BGP table..




















Expressions are used in the order of the table..







No comments:

Post a Comment