cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
569
Views
0
Helpful
4
Replies

BGP regex question.

nikhil.kulkarni
Level 1
Level 1

Folks,

I am looking to combine more than one regex into a single expression:

I have regex number 65001, 65002, 65003, 65004 upto 65030 into a single regex.

ip as-path access-list 10 permit _65001$

ip as-path access-list 20 permit _65002$

ip as-path access-list 30 permit _65003$

.

.

.

ip as-path access-list 300 permit _65030$

Is this below regex correct?

ip as-path access-list 10 permit _650[01-30]$

Thanks,

Nik

4 Replies 4

cadet alain
VIP Alumni
VIP Alumni

Hi,

I don't think this is possible with one line but i'm not a regexp expert though.

Anyway I think it can be done in 2 lines with:

ip as-path access-list 10 permit _650[0-2][0-9]$

ip as-path access-list 20 permit _65030$

Regards.

Alain

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.

Hi Nik and Alain,

Nik, the abbreviated as-path ACL you have suggested is not correct. The expression in brackets is always evaluated as a single character from a defined set. Your expression [01-30] defines a set that contains digits '0' (defined twice), '1', '2', and '3'. It is only a single digit, though. Your abbreviated as-path ACL therefore results into just four AS numbers: 6500, 6501, 6502, and 6503.

Alain, I believe it is possible to create a single-line as-path ACL that will do what Nik requires, however, the resulting regexp will require using the alternation operator. I believe you are correct in your assumption that you cannot write a single regular expression without this operator that will correctly match the range 65000 - 65030. The regexp can be, e.g.:

_650([0-2][0-9]|30)^

It has to be noted, though, that this form strongly reduces the readability and clarity of this expression, and therefore, I would not recommend using it. Over-optimizing things actually degrades them.

Best regards,

Peter

Hi Peter,

I'll try it on GNS3 , thanks for the info.

Regards.

Alain

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.

Joseph W. Doherty
Hall of Fame
Hall of Fame

Disclaimer

The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.

Liability Disclaimer

In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.

Posting

_650([0-2][1-9]|10|20|30)_

Above is a variation of what Peter suggests, excluding 65000.

Review Cisco Networking for a $25 gift card