BGP Regular Expression

1. Atom  An atom is a single character, such as the following

.

Matches any single character

^(Carat)

– Matches the beginning of the input string 

ex) ^5

    it will match with the below

        5  100 712
500 3000 6577

        548 453 343

ex) show ip bgp regexp 5

    it will match with the below
500 4390 4000

        100 598 4130

        200 453 3400 

$

– Matches the end of the input string   

ex) 500$

    it will match with the below

      100 768 500

      100 675 3500

      343 233 4572 345 500 

  \

– Matches the character

_

Matches a comma (,), left brace ({), right brace (}), the beginning of the input string, the end of the input string, or a space.

 

ex)  _10_
1230 10 344 7119
10 2323 3000
5003 345 7001 10    

  [ ] – Define a range
ex) [1-9]346
1346
2346
3346
:
ex) 2[1234]7
217
227
237    

 

2. Piece   A piece is an atom followed by one of the following symbols

 *

    Matches 0 or more sequences of the atom

+

    Matches 1 or more sequences of the atom

?

    Matches the atom or the null string

 

3. Branch   A branch is a 0 or more concatenated pieces

a*

    Any occurrence of the letter “a”, including none

a+

    At least one occurrence of the letter “a” should be present)

ab?a

    This matches “aa” or “aba

_100_

    Via AS100
ex) 100 3345 768 232
2300 100 244 716

^100$

    Origin AS100

ex) sh ip bgp regexp ^100$

      100

^100 .*

    Coming from AS100

^.100  ex) sh ip bgp regexp ^.100
       1100
       4100
       8100
 _[1-9]567$  ex)  344 1567
         50 232 3567
        100 4546 8567
 ^5[1-4]7_  ex) 517 456
       537 400 234
       527 300 232
 ^100_  ex) sh ip bgp regexp ^100_
       100 345 213
       100 200

^$

    Originated from this AS

 

Share:

Author: Chris Yoon

IT professional