Nothing Special   »   [go: up one dir, main page]

40-BGP Regular Expression

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

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.

Character/Symbol Special Meaning


Asterisk * Matches 0 or more sequences of the pattern.
Brackets [] Designates a range of single-character patterns.
Caret ^ Matches the beginning of the input string.
Dollar Sign $ Matches the end of the input string.
Hyphen - Separates the end points of a range.
Parentheses () Logical grouping.
Period . Matches any single character, including white space.
Plus Sign + Matches 1 or more sequences of the pattern.
Question Mark ? Matches 0 or 1 occurrences of the pattern.
Underscore _ Matches a space.
Pipe | Provides or functionality to the query.
Caret in brackets [^] Excludes the characters listed in brackets.

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

1 | P a g e Created by Ahmad Ali E-Mail: ahmadalimsc@gmail.com , Mobile: 056 430 3717


Create a regular expression that shows all networks that originate in AS 7474.
Show ip bgp regexp _7474$

To find all subnets reachable via AS 7474 (AS path begins with 7474).
show ip bgp regexp ^7474_

2 | P a g e Created by Ahmad Ali E-Mail: ahmadalimsc@gmail.com , Mobile: 056 430 3717


Create a regular expression that shows AS 7474 at the beginning, and everything behind it.
Show ip bgp regexp ^7474_

Shows everything where AS 6762 is in the middle of the AS-PATH.


show ip bgp regexp _6762_

3 | P a g e Created by Ahmad Ali E-Mail: ahmadalimsc@gmail.com , Mobile: 056 430 3717


Create a regular expression that only shows the locally originated networks.
Show ip bgp regexp ^$

To match all the networks in BGP table.


Show ip bgp regexp .*

Show all networks that are originated by your directly connected AS neighbors.
Show ip bgp regexp ^[0-9]+$

4 | P a g e Created by Ahmad Ali E-Mail: ahmadalimsc@gmail.com , Mobile: 056 430 3717


Create a regular expression that only shows AS 7474.
Show ip bgp regexp ^7474$

5 | P a g e Created by Ahmad Ali E-Mail: ahmadalimsc@gmail.com , Mobile: 056 430 3717

You might also like