cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
810
Views
3
Helpful
12
Replies

BGP Regexp Questiion

Teck Sing
Level 1
Level 1

Dear experts

There's an example in <300-410 Official Cert Guide>:

This is original BGP table:

TeckSing_0-1722389802155.png

After issue show bgp ipv4 unicast regexp (10)+[^(100)] command, the result in book is:

TeckSing_1-1722390071761.png

But when I did it on my machine, only two prefixes are visible: 172.16.192.0/24 and 192.168.129.0/24. Does anyone please explain this regexp in detail? Or is there any article or document or book expound it deeply?

Thanks a lot

- Teck Sing

1 Accepted Solution

Accepted Solutions

Harold Ritter
Level 12
Level 12

Hi @Teck Sing ,

I suppose there has been a changed in the regexp engine behavior since the book guide has been released. The behavior you are seeing makes sense.

172.16.4.0/23 and 192.168.4.0/23 are rejected because the (10)+ matches all the occurences of 10 in the AS path, which leads you to the end of the AS path. The regexp then searches for a value that different than 100 (^100). This value is not found as the end of the AS path is reached.

Regards, 

Harold Ritter
Sr Technical Leader
CCIE 4168 (R&S, SP)
harold@cisco.com
México móvil: +52 1 55 8312 4915
Cisco México
Paseo de la Reforma 222
Piso 19
Cuauhtémoc, Juárez
Ciudad de México, 06600
México

View solution in original post

12 Replies 12

Did you configure it exactly like the example in the book? You have network 172.16.192.0/24 but thats not even a network in the example you provided.

Secondly, Are all your routes going through all the AS#s provided by the book example. Can you provide your configuration and topology? It needs to mimic the book exactly to get the same results most likely.

 

-David

Hi, David

172.16.192.0/24 is a typo, it's 172.16.129.0/24. I've topology like this:

TeckSing_1-1722406604983.png

and use loopback interfaces to simulate prefixes on R1 and R3 (they are in AS100 and AS300 respectively), the AS-Path list is prepended via route-map. So on R2, I got BGP table exactly same as the book's. 

TeckSing_0-1722406573904.png

I run all examples in book, there's no problem except for this one. So I wonder what's the meaning of (10)+[^(100)] in this regexp query, especially [^(100)]? Because I change the number in the parentheses, could lead to different results. 

TeckSing_2-1722407500100.png

Thanks! 

- Teck Sing

 

paren is grouping and + means 1 or more so (10)+ equals one or more 10.   A caret ^ inside a square bracket [^ means NOT so [^(100)] means NOT 100.  put that together (10)+[^(100)] and you have one or more 10 followed by NOT 100. Your example looks like your caret is very large and your keyboard could be set for unicode and sending Arabic-Indic Digit Eight ٨ and not ascii caret ^.

 

Hi, Dan

Thanks. But in another example, the caret ^ works as expected like below:

TeckSing_0-1723008372010.png

BTW, how to set keyboard? 

- Teck Sing

please share roue-map for prepend let me check in lab 

MHM

Hi, MHM

Here's route-map and ACL on one router for your reference. Appreciate you'll check in your lab. 

TeckSing_1-1723008693641.png

- Teck Sing

M02@rt37
VIP
VIP

Hello @Teck Sing 

The regex (10)+ matches one or more occurrences of the string "10", so it will match paths like "10", "1010", "101010", etc.

The [^(100)] part is a character class that matches any single character that is not `(`, `1`, `0`, or `)`. Therefore, the command filters AS_PATHs that contain one or more instances of "10" consecutively, followed by any character that is not one of `(`, `1`, `0`, or `)`. For example, AS_PATHs like `10 20 30` or `1010 2020 3030` would match because they meet these criteria.

Check book like "BGP Design and Implementation" by Randy Zhang.

Best regards
.ı|ı.ı|ı. If This Helps, Please Rate .ı|ı.ı|ı.

Hello, M02@rt37 

If router treats '(' and ')' as common character in square brackets, escape character is not needed? 

Thanks

- Teck Sing

Harold Ritter
Level 12
Level 12

Hi @Teck Sing ,

I suppose there has been a changed in the regexp engine behavior since the book guide has been released. The behavior you are seeing makes sense.

172.16.4.0/23 and 192.168.4.0/23 are rejected because the (10)+ matches all the occurences of 10 in the AS path, which leads you to the end of the AS path. The regexp then searches for a value that different than 100 (^100). This value is not found as the end of the AS path is reached.

Regards, 

Harold Ritter
Sr Technical Leader
CCIE 4168 (R&S, SP)
harold@cisco.com
México móvil: +52 1 55 8312 4915
Cisco México
Paseo de la Reforma 222
Piso 19
Cuauhtémoc, Juárez
Ciudad de México, 06600
México

Hello, Harold

It seems you are right. When I add another AS number at the end of 192.168.4.0/23 AS_Path list, this prefix appears.  

TeckSing_0-1723010935629.png

Thanks a lot! 

- Teck Sing

You are very welcome @Teck Sing and thanks for the feedback

Harold Ritter
Sr Technical Leader
CCIE 4168 (R&S, SP)
harold@cisco.com
México móvil: +52 1 55 8312 4915
Cisco México
Paseo de la Reforma 222
Piso 19
Cuauhtémoc, Juárez
Ciudad de México, 06600
México
Review Cisco Networking for a $25 gift card