RE: BGP regexp, doubt..?!

From: Scott Morris (smorris@internetworkexpert.com)
Date: Fri Dec 19 2008 - 03:54:39 ARST


Re-reading before sending... Takes all the fun out of it! :)

  _____

From: Andy Hogard [mailto:andyhogard@gmail.com]
Sent: Friday, December 19, 2008 12:51 AM
To: Tyson Scott
Cc: smorris@internetworkexpert.com; Cisco certification
Subject: Re: BGP regexp, doubt..?!

Oh sorry,

Tyson is from IpExpert!! Kewl ..Lucky Tony. I think I must better go wash my
face and have coffee, before I yank out any more emails.

Heheh,

Greets,
Andy.

PS: Tony that only leaves you with one scott to handle. :P I must stop
pulling his leg, before he does a slamdunk on me ya.

On Fri, Dec 19, 2008 at 11:10 AM, Andy Hogard <andyhogard@gmail.com> wrote:

Hmm, yep thats what I was looking for "^([\([0-9 ]+\)]*)?$" actually I was
pretty close to it, but every time I tried to multiply this atom \([0-9 ]+\)
by a * or ? it gave me an error saying that they cannot operate on a null
atom. What the key here was the use of "[]" which would have cut my work. :D

Thanks a lot for your help, sir.

Regards,
Andy.

PS: How many Scotts exists at IE, poor Tony must be finding it hard. ;)

On Fri, Dec 19, 2008 at 9:03 AM, Tyson Scott <tscott@ipexpert.com> wrote:

Andy,

^\(([0-9]*)|([0-9]*)\)$ does not equal ^(\(.+\)?$

The first regular expression will match anything that has a confederation in
the beginning in addition to any other AS's that follow, as is shown below:

R2#sh ip bgp regexp ^\(([0-9]*)|([0-9]*)\)$

BGP table version is 796, local router ID is 200.0.0.2

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

*> 100.100.200.0/24 150.100.100.5 0 100 0 (64513) 7800 i
*> 100.100.250.0/24 150.100.100.5 0 100 0 (64513 64514)
19999 i
*> 102.0.0.0/22 150.100.100.5 0 100 0 (64513 64514)
19999 3561 ?
*> 102.0.16.0/20 150.100.100.5 0 100 0 (64513 64514)
19999 3561 ?
*> 102.0.32.0/22 150.100.100.5 0 100 0 (64513 64514)
19999 3561 ?
*> 102.0.48.0/22 150.100.100.5 0 100 0 (64513 64514)
19999 3561 ?
*> 102.0.64.0/22 150.100.100.5 0 100 0 (64513 64514)
19999 3561 ?
*> 102.0.80.0/22 150.100.100.5 0 100 0 (64513 64514)
19999 3561 ?

The second regular expression matches the routes whether it has a
confederation peer in the path or if it originates in its own AS.

The second regular expression is definitely the most simplistic and I would
recommend using it but here is the more complex regular expression that
would be equal to it.

^([\([0-9 ]+\)]*)?$
Or
^([\([0-9 ]*\)]*)?$

R2#sh ip bgp regexp ^([\([0-9 ]*\)]*)?$

BGP table version is 796, local router ID is 200.0.0.2

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

*> 150.100.12.0/24 0.0.0.0 0 32768 i
*> 150.100.24.0/24 0.0.0.0 0 32768 i
* 150.100.25.0/24 150.100.100.5 0 100 0 (64513) i
*> 0.0.0.0 0 32768 i
*>i150.100.40.0/24 150.100.24.4 0 100 0 i
*>i150.100.41.0/24 150.100.24.4 0 100 0 i
*> 150.100.100.0/24 0.0.0.0 0 32768 i
*> 150.100.220.0/24 150.100.100.5 0 100 0 (64513) i
*> 150.100.221.0/24 150.100.100.5 0 100 0 (64513) i
*> 200.0.0.2/32 0.0.0.0 0 32768 i
*>i200.0.0.4/32 150.100.24.4 0 100 0 i
*> 200.0.0.5/32 150.100.100.5 0 100 0 (64513) i
*> 200.0.0.6/32 150.100.100.5 0 100 0 (64513 64514) i
*> 222.255.2.0 150.100.100.5 0 100 0 (64513) i
*> 222.255.3.0 150.100.100.5 0 100 0 (64513) i

  Network Next Hop Metric LocPrf Weight Path

*> 222.255.6.0 150.100.100.5 0 100 0 (64513) i
*> 222.255.7.0 150.100.100.5 0 100 0 (64513) i
R2#

R2#sh ip bgp regexp ^(\(.+\))?$

BGP table version is 796, local router ID is 200.0.0.2

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

*> 150.100.12.0/24 0.0.0.0 0 32768 i
*> 150.100.24.0/24 0.0.0.0 0 32768 i
* 150.100.25.0/24 150.100.100.5 0 100 0 (64513) i
*> 0.0.0.0 0 32768 i
*>i150.100.40.0/24 150.100.24.4 0 100 0 i
*>i150.100.41.0/24 150.100.24.4 0 100 0 i
*> 150.100.100.0/24 0.0.0.0 0 32768 i
*> 150.100.220.0/24 150.100.100.5 0 100 0 (64513) i
*> 150.100.221.0/24 150.100.100.5 0 100 0 (64513) i
*> 200.0.0.2/32 0.0.0.0 0 32768 i
*>i200.0.0.4/32 150.100.24.4 0 100 0 i
*> 200.0.0.5/32 150.100.100.5 0 100 0 (64513) i
*> 200.0.0.6/32 150.100.100.5 0 100 0 (64513 64514) i
*> 222.255.2.0 150.100.100.5 0 100 0 (64513) i
*> 222.255.3.0 150.100.100.5 0 100 0 (64513) i

  Network Next Hop Metric LocPrf Weight Path

*> 222.255.6.0 150.100.100.5 0 100 0 (64513) i
*> 222.255.7.0 150.100.100.5 0 100 0 (64513) i
R2#

Regards,

Tyson Scott - CCIE #13513 R&S and Security
Technical Instructor - IPexpert, Inc.

Telephone: +1.810.326.1444
Fax: +1.810.454.0130
Mailto: tscott@ipexpert.com

-----Original Message-----
From: nobody@groupstudy.com [mailto:nobody@groupstudy.com] On Behalf Of Andy
Hogard

Sent: Thursday, December 18, 2008 3:54 PM
To: smorris@internetworkexpert.com

Cc: Cisco certification
Subject: Re: BGP regexp, doubt..?!

:D (Back with a huge grin)

What worked for me was this regexp --> ^\(([0-9]*)|([0-9]*)\)$

R2#sh ip bgp regexp ^\(([0-9]*)|([0-9]*)\)$
BGP table version is 12, local router ID is 155.1.23.2
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
*> 3.0.0.0 155.1.23.3 0 100 0 (64530) i
*> 33.0.0.0 155.1.23.3 0 100 0 (64530 64500
64600) i
*> 204.12.1.0 155.1.13.1 0 100 0 (64530 64510)
300 i
R2#

The original bgp table looks something like this,

R2#sh ip bgp
BGP table version is 12, local router ID is 155.1.23.2
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
*> 3.0.0.0 155.1.23.3 0 100 0 (64530) i
*> 33.0.0.0 155.1.23.3 0 100 0 (64530 64500
64600) i
*> 155.1.5.0/24 155.1.0.5 0 0 100 i
*> 204.12.1.0 155.1.13.1 0 100 0 (64530 64510)
300 i
R2#

If anyone else can come up with something more nifty please help me out.

Regards,
Andy.

PS: Definitely off to bed this time. :)

On Fri, Dec 19, 2008 at 2:11 AM, Andy Hogard <andyhogard@gmail.com> wrote:

> Ok,
>
> I am sorry to say but my proposed solutions do not work ya,
>
> R2#sh ip bgp
> BGP table version is 4, local router ID is 155.1.23.2
> 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
> *> 3.0.0.0 155.1.23.3 0 100 0 (64530) i
> *> 155.1.5.0/24 155.1.0.5 0 0 100 i
> *> 204.12.1.0 155.1.13.1 0 100 0 (64530 64510)
> 300 i
> R2#
>
> On this table, so far what works is this --> ^(\([0-9]*)
>
> R2#sh ip bgp regexp ^(\([0-9]*)
> BGP table version is 4, local router ID is 155.1.23.2
> 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
> *> 3.0.0.0 155.1.23.3 0 100 0 (64530) i
> *> 204.12.1.0 155.1.13.1 0 100 0 (64530 64510)
> 300 i
> R2#
>
> I even made some modifications to the routing table of R3, such that the
> table on R2 would like as shown below,
>
> R2#sh ip bgp
> BGP table version is 12, local router ID is 155.1.23.2
> 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
> *> 3.0.0.0 155.1.23.3 0 100 0 (64530) i
> *> 33.0.0.0 155.1.23.3 0 100 0 (64530 64500
> 64600) i
> *> 155.1.5.0/24 155.1.0.5 0 0 100 i
> *> 204.12.1.0 155.1.13.1 0 100 0 (64530 64510)
> 300 i
> R2#
>
> And again tested the, regexp of ^(\([0-9]*)
>
> R2#sh ip bgp regexp ^(\([0-9]*)
> BGP table version is 12, local router ID is 155.1.23.2
> 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
> *> 3.0.0.0 155.1.23.3 0 100 0 (64530) i
> *> 33.0.0.0 155.1.23.3 0 100 0 (64530 64500
> 64600) i
> *> 204.12.1.0 155.1.13.1 0 100 0 (64530 64510)
> 300 i
> R2#
>
> Its clear that from the as-path of (64530 64510) 300 its just matching the
> * (64530* 64510) 300 highlighted part.
>
> Finally lets test the well know, regexp made for this purpose and posted
on
> the IE blog.. ^(\(.+\))?$
>
> R2#sh ip bgp regexp ^(\(.+\))?$
> BGP table version is 12, local router ID is 155.1.23.2
> 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
> *> 3.0.0.0 155.1.23.3 0 100 0 (64530) i
> *> 33.0.0.0 155.1.23.3 0 100 0 (64530 64500
> 64600) i
> R2#
>
> Hah! This one also just matched two routes, where as it should have hit
> three prefixes ya. Now can we all together complete this complex mess.
>
>
> Dead, tired hitting the bed.
>
>
> Greets,
> Andy.
>
>
>
> On Thu, Dec 18, 2008 at 11:45 PM, Andy Hogard <andyhogard@gmail.com>wrote:
>
>> Yep, the best would be to put it to test on a lab. Will do that in the
>> morning ya. Its night here, actually I came up with the solutions using
your
>> ideas and how you explained in the one of the vods ya.
>>
>> Will update you and the list in sometime, actually I am itching already.
>> So let me build a quick scenario ..and lets see how all three do.
>>
>> Regards,
>> Andy.
>>
>>
>> On Thu, Dec 18, 2008 at 11:40 PM, Scott Morris <
>> smorris@internetworkexpert.com> wrote:
>>
>>> Since you are specifically looking for things inside a confederation,
the
>>> "(" and ")" are the parts we care about.
>>>
>>> My only concern about the first one you lise is that you are looking for
>>> 0
>>> or 1 (the ?) of ([0-9]*_) which would match none or one AS that must be
>>> inside ( ) for a confederation.
>>>
>>> The second one will definitely work with your example below as it's
>>> permitting any characters (numbers or spaces) as long as they are
>>> contained
>>> within the ( ) for a confederation.
>>>
>>> I don't have a confederation currently setup in my lab, so I can't
>>> specifically test out the first one, but when it came to the AS Path you
>>> listed below with multiple intra-confed ASNs listed, I would be curious
>>> as
>>> to whether it matched or not.
>>>
>>>
>>> Scott Morris, CCIE4 #4713, JNCIE-M #153, JNCIS-ER, CISSP, et al.
>>> CCSI/JNCI-M/JNCI-ER
>>> Senior CCIE Instructor
>>>
>>> smorris@internetworkexpert.com
>>>
>>>
>>>
>>> Knowledge is power.
>>> Power corrupts.
>>> Study hard and be Eeeeviiiil......
>>>
>>>
>>> -----Original Message-----
>>> From: nobody@groupstudy.com [mailto:nobody@groupstudy.com] On Behalf Of
>>> Andy
>>> Hogard
>>> Sent: Thursday, December 18, 2008 2:07 AM
>>> To: Cisco certification
>>> Subject: Re: BGP regexp, doubt..?!
>>>
>>> Sorry one last final correction, ^\(([0-9]*_)?\)$ <==> ^(\(.+\))?$ .
>>> Yep
>>> are the two regexp the same ?! :)
>>>
>>> Might have looked like I was just losing my remaning hair over it.. lol.
>>>
>>>
>>> Greets!
>>>
>>> On Thu, Dec 18, 2008 at 12:18 PM, Andy Hogard <andyhogard@gmail.com>
>>> wrote:
>>>
>>> > Actually looks like I made a small typo, it should be is
>>> > ^(\([0-9]*_)?\)$ <==> ^(\(.+\))?$ ..!? :)
>>> >
>>> >
>>> > Regards,
>>> > Andy,
>>> >
>>> > PS: I will consider regexp done if I get this correct!! :D
>>> >
>>> > On Thu, Dec 18, 2008 at 12:13 PM, Andy Hogard <andyhogard@gmail.com
>>> >wrote:
>>> >
>>> >> Hi folks,
>>> >>
>>> >>
>>> >> I just wanted to know whether ^(\([0-9]*_\))?$ <==> ^(\(.+\))?$
>>> ..?!
>>> >> Let me know what you think, my goal was to prevent a confederated AS
>>> >> from becoming a transit path, the reg exp that you see on your left
>>> >> is what I came up with and on the left that's a well know one from
>>> >> the IE blog. To me both seem to be the same,
>>> >>
>>> >> I will try and explain in brief here:
>>> >>
>>> >> (65535 64512 64513) thats how the as path would be like for the
>>> >> routes that originated within the AS. I need to match these and be
>>> >> able to export these out to the external AS ..whereas others which
>>> >> have (65535 64512 64513) 100 200 300 must be blocked.
>>> >>
>>> >> So [0-9] is my atom here, since I can have zero or multiple instances
>>> >> of these will use it with a *
>>> >>
>>> >> Hence arrive at [0-9]* , I need to match ( ) which is a special
>>> >> character so I will use "\", but before that a bracket operation for
>>> >> my atom. And obviously I will encose them within ^$, as thats what I
>>> need
>>> in my as path.
>>> >> My doubt here is that do I have to use [0-9]*_ as my atom or is just
>>> >> [0-9]* enough to match the blank spaces separating the two intra
>>> confed
>>> as nos. ya.
>>> >>
>>> >>
>>> >> Let your thoughts and comments flow
>>> >>
>>> >>
>>> >> Regards,
>>> >> Andy.
>>> >> --
>>> >> My Blog URL: http://ccieno.blogspot.com/
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > My Blog URL: http://ccieno.blogspot.com/
>>> >
>>>
>>>
>>>
>>> --
>>> My Blog URL: http://ccieno.blogspot.com/
>>>
>>>
>>> Blogs and organic groups at http://www.ccie.net
>>>
>>> _______________________________________________________________________
>>> Subscription information may be found at:
>>> http://www.groupstudy.com/list/CCIELab.html
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>> --
>> My Blog URL: http://ccieno.blogspot.com/
>>
>
>
>
> --
> My Blog URL: http://ccieno.blogspot.com/
>

--
My Blog URL: http://ccieno.blogspot.com/

Blogs and organic groups at http://www.ccie.net



This archive was generated by hypermail 2.1.4 : Thu Jan 01 2009 - 12:53:09 ARST