40-BGP Regular Expression
40-BGP Regular Expression
40-BGP Regular Expression
A regular expression is a pattern used to match against an input string. It is a widely used tool.
In BGP routing policy deployment, regular expressions can also be flexibly used to obtain
routes. A BGP route contains the AS_Path attribute. Regular expressions can be used to obtain
routes with a specific AS number or AS_Path attribute. Regular expressions are strings of special
characters that can be used to search and find character patterns. Within the scope of BGP in
Cisco IOS regular expressions can be used in show commands and AS-Path access- lists to match
BGP prefixes based on the information contained in their AS-Path. A regular expression is a
formula for matching strings that follow a certain pattern. It evaluates text data & returns an
answer of true or false. BGP Regular Expressions are special characters used to get useful
information from BGP tables. Use the show ip bgp regexp command to display routes matching
the specified regular expression.
Expression Meaning
.* Anything
^$ Locally originated Routes
^ 7474 _ Learned from AS 7474
_ 7474$ Originated in AS 7474
_ 7474_ Any instance of AS 7474
^[0-9]+$ Directly Connected AS
https://bgp4.as/looking-glasses
To find all subnets reachable via AS 7474 (AS path begins with 7474).
show ip bgp regexp ^7474_
Show all networks that are originated by your directly connected AS neighbors.
Show ip bgp regexp ^[0-9]+$