BGP Regular Expressions
filed in Cisco Networking on Sep.23, 2009
Autonomous system path filtering with regular expressions
String matching—A string of characters in the regular expression matches any equivalent substring in the autonomous system path; 29 has three matches in | 210 291 1296 29 |, for example.
String matching alternatives—The pipe symbol (|) means “or.”
String matching ranges and wildcards—Brackets ([ ]) can be used for ranges, and the period (.) can match any single character.
String matching delimiters—The caret (^) matches the beginning of string, the dollar sign ($) matches the end of the string, and an underscore (_) matches any delimiters.
String matching grouping—Parentheses can group smaller expressions into larger expressions.
String matching special characters—You can use the backslash (\) to remove the special meaning of the character that follows.
String matching repeating operators—An asterisk (*) means the expression preceding repeats zero or more times, a question mark (?) means the expression preceding repeats zero or one time, and a plus sign (+) means the expression preceding repeats one or more times.
_200_ - All routes going through autonomous system 200
^200$ - Directly connected to autonomous system 200
_200$ - Originated in autonomous system 200
^200_. - Networks behind autonomous system 200
^[0-9]+$ - Autonomous system paths one autonomous system long
^([0-9]+)(_\1)*$ - Networks originating in the neighbor autonomous system
^$ - Networks originated in local autonomous system
.* - Matches everything

Leave a Reply