cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
847
Views
4
Helpful
5
Replies

BGP AS regex question.

nikhil.kulkarni
Level 1
Level 1

Folks,

I had asked this question earlier but just to refresh my discussion on the regex in BGP, I am looking to consolidate my AS numbers 65350 to 65379 into one statement.

Is the below staement correct?

_653[5-7][0-9]$

The regex is supposed to accomadate all the routes originated from AS number 65350 to 65379.

Thanks,

Nikhil.

5 Replies 5

milan.kulik
Level 10
Level 10

Yes, it's correct.

BR,

Milan

Thanks Milan,

I have a small twist to my question here:

I want to advertise these routes learnt from AS 65350 to 65379 only under the condition that the AS path is seen twice in the AS list.

Is the below correct then?

_653[5-7][0-9]_653[5-7][0-9]$

Thanks,

Nikhil.

Hi,

that would match different AS numbers from the 65350 - 65379 range too.

_65351_65352$, e.g.

If you want to match only the same  AS number seen twice, you need something like

_(653[5-7][0-9])_\1$

See http://www.cisco.com/en/US/products/hw/switches/ps718/products_command_reference_chapter09186a008009166c.html#1003461

for details.

HTH,

Milan

something like:

_(653[5-7][0-9])_\2$

is this not supported?

Regards,

Nikhil Kulkarni.

Hi,

the document says:

"The integer specifies the occurrence of a parentheses in the regular expression pattern. If you have more than one remembered pattern in your regular expression, then \1 uses the first remembered pattern and \2 uses the second remembered pattern, and so on."

So iy has no sense to use

_(653[5-7][0-9])_\2$

as there is only one pair of parentheses there.

So you need to use

_(653[5-7][0-9])_\1$

in this case.

\2 may be used in more complicated cases where a second pair of parentheses is used to remember the second pattern.

BR,

Milan

Review Cisco Networking products for a $25 gift card