Matching on ^ASPath_ASPath$ Prepending information.

Suppose you want to find all routes that have the same AS number in a row 8 or more times…

is this possible using regexp?

Yes you can ūüôā

using this Regular Expression

^([0-9]+)(_\1)*$

With regular expression we can match in Prepended information performed in neighboring originating AS.

R1(config-router)#do show ip bgp reg ^([0-9]+)(_\1)*$
BGP table version is 3, local router ID is 172.22.81.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 2.2.2.0/24       172.22.142.2             0             0 2 2 2 2 2 2 2 2 2 ?

AS Prepeding, means for me in a simple term a multiplication of directly connected AS Number.

R6(config)#do show ip bgp | b Net

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.1/32       172.22.83.1                            0 4321 4321 4321 ?
*> 3.3.3.3/32       172.22.83.1              0             0 4321 400 400 400 400 400 ?
*> 33.33.0.0/16     172.22.83.1              0             0 4321 100 100 100 100 100 ?

R6(config)#do show ip bgp regex ^([0-9]+)(_\1)*$| b Net
BGP table version is 87, local router ID is 172.217.43.6

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.1/32       172.22.83.1                            0 4321 4321 4321 ?

the expression

^([0-9]+)(_\1)*$

in the first parenthesis, matches any AS Number, the parenthesis stores the value of the matched ASNumber, and this value is called by the second part of the regular expression, in the Variable “\1” is like where you store the result and clearly you repeat this value zero or more atoms, and the $ matches the end of the string.

if you are looking for more information, here is a nice article wrote by Brian McGahan about Understanding BGP Regular Expressions

A Networker Blog

Advertisements

One thought on “Matching on ^ASPath_ASPath$ Prepending information.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s