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

BGP AS-path filtering

frenzeus
Level 4
Level 4

In regexp, how is the underscore used? From Cisco docs it says, _ can be used to replace a comma (,), left brace {, right brace }, ^, $ and space. This is in regards to using regexp in BGP as-path filtering. The objective is to prevent a client peered to one of the isp edge routers from advertising transit routes to the isp edge router. Let’s say the client’s AS is 779. The task is to permit only prefixes originated from AS 779. Prefixes with the following as-path is allowed:

1.) 779

2.) 779 779

Prefixes with the following as-path is not allowed:

3.) 779 1224

Having some prefix pre-pended with their own AS will rule out the option of using ^779$. The usage of _779_ however would exclude prefixes with other AS in the as-path string. My understanding of underscore is to include any string; meaning _779_ includes any string that is before and after 779. So correct me if I’m wrong.

Thank you all so much. Confused!

1 Accepted Solution

Accepted Solutions

Harold Ritter
Cisco Employee
Cisco Employee

You are correct in saying that _779_ would allow any aspath that includes 779 regardless what is before or after.

In you scenario, you want something like _779$.

Let me know if I answered your question,

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

4 Replies 4

Harold Ritter
Cisco Employee
Cisco Employee

You are correct in saying that _779_ would allow any aspath that includes 779 regardless what is before or after.

In you scenario, you want something like _779$.

Let me know if I answered your question,

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

Hi,

Thanks. Yah, that was just what I needed. But I'm still confused as to how using _779_ actually did filter out prefixes with AS path 779 1224 when I tried it out.

But _779$ really makes sense, anything that ends with 779, including what is before 779. This definitely does exclude other prefixes that were originated from other AS passing through 779.

I'm not sure why _779_ filtered out aspath 779 1224 but it shouldn't have as it matches.

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

Try this one:

^779(_(779))*$

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:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco