cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5321
Views
0
Helpful
11
Replies

BGP Regular Expression for 64512-65535 (Private ASs)

kfarrington
Level 3
Level 3

Is there a regexp for BGP private ASs.

I would like to put them in an expanded community-list?

Many kind regards,

Ken

1 Accepted Solution

Accepted Solutions

Ken,

You need to specify the ^ and $ only at the beginning and at the end. The following community-lists should do what you want.

R1#sh ip community-list

Named Community expanded list group1

permit ^64[6-8][0-9][0-9]:123$

Named Community expanded list group2

permit ^649[0-9][0-9]:123|65[0-1][0-9][0-9]:123$

Named Community expanded list group3

permit ^65[2-5][0-9][0-9]:123$

Hope this helps,

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

11 Replies 11

Harold Ritter
Cisco Employee
Cisco Employee

I'm not sure I understand your question. regexp works for all ASNs. Could you please clarify your question.

Thanks,

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

Sorry about that,

I want to match a specific community value (a global LP community setting) so when I receive this community value privateas:xxxx i will set the attribute.

So, if we had a private AS range in the following regions set

Region AS Range

Region1 64600 – 64899

Region2 64900 – 65199

region3 65200 – 65535

if I receive a community value of any of the above ASs with a :123 i will set LP to 95.

ip community-list expanded companyASs permit ^64[6-9][0-9][0-9]$:123

ip community-list expanded companyASs permit ^65[0-4][0-9][0-9]$:123

ip community-list expanded companyASs permit ^655[0-2][0-9]$:123

ip community-list expanded companyASs permit ^6553[0-5]$:123

Is there a way to use regular expressions to match all of these ASs in one line and thus cut the config down?. I am not a big regexp master?

Kind regards,

Ken

I have just seen the OR funtion

no ip community-list expanded companyASs

ip community-list expanded companyASs permit _64[6-9][0-9][0-9]:123_|_65[0-4][0-9][0-9]:123_|_655[0-2][0-9]:123_|_6553[0-5]:123_

but funny how the ^ and $ donot work with the or function

no ip community-list expanded companyASs

ip community-list expanded companyASs permit ^64[6-9][0-9][0-9]:123$|^65[0-4][0-9][0-9]:123$|^655[0-2][0-9]:123$|^6553[0-5]:123$

I like using the carrat dollar, but dont thin I can, unless anyone knows to the contary?

Best regards as always,

Ken

Ken,

You need to specify the ^ and $ only at the beginning and at the end. The following community-lists should do what you want.

R1#sh ip community-list

Named Community expanded list group1

permit ^64[6-8][0-9][0-9]:123$

Named Community expanded list group2

permit ^649[0-9][0-9]:123|65[0-1][0-9][0-9]:123$

Named Community expanded list group3

permit ^65[2-5][0-9][0-9]:123$

Hope this helps,

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

thx, thats gr8 fella.

many thx as usual :)

Hi hritter,

Shouldn't the last one be

^65[2-5][0-3][0-5]:123$

The below range is what Ken was looking at, right ?

region3 65200 – 65535

Regards

Arav.

Your regexp only allows 65200 to 65235, 65300 to 65335, 65400 to 65435 and 65500 to 65535.

The regular expression I suggested (65[2-5][0-9][0-9]) allows 65200 to 65599 but no community can be larger than 65535 anyway.

Hope this helps,

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

Quick one just to end up with on this is.

can we just have a community-list that either says :-

ip community-list standard/expanded permit range 64512 65535

or

ip community-list standard/expanded permit private-as-range

:)

man, could i raise a feature request for it?

if it was that easy though, we would all be out on our ears :))

many thx to all for their input :)

the pub opens in 2h4m - cant wait!!

I guess it would be nice to call the private AS range by name just like we do for the internet, local-AS, no-advertise and no-export communities.

Please have a pint for me ;o)

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,

This subject has probably been beaten to death but I looked into the same issue about a year ago and this is the one line regular expression that somebody suggested that seemed to work just fine:

_6451[2-9]_|_645[2-9][0-9]_|_64[6-9][0-9][0-9]_|_65[0-4][0-9][0-9]_|_655[0-2][0-9]_|_6553[0-5]_

I know it is bordering on ridiculous but it works :-)

BGP Regular Expression for 64512-65535 (Private ASs)

this is for 16bit private ASs

ip as-path access-list 66 permit

_(6451[2-9]|645[2-9][0-9]|64[6-9][0-9][0-9]|65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])_

so

so this regex 64[5-9][0-9][0-9]|65[0-5][0-9][0-9] won't work with 32bit private AS's)

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Review Cisco Networking products for a $25 gift card