2.8 (regular expression)

The SG has the expression:

^100(_[0-9]+)?$

I used the following:

 ^_100_[0-9]*$

Would mine work? I got prefixes just in AS100 and prefixes one AS away. I did not get prefixes two ASes away which is the desired behavior.

Comments

  • I'm not a regex expert but I think your first _ is redundant and possibly "wrong" as technically there is no AS PATH that will start the path with an empty space.  I find your method easier to read though!

  • I got in the habit of putting the leading _ so as not to match similar ASes with a leading number. Example: 1200 or 200. The _ prevents from matching the 1200.

     

  • I'm pretty sure it works fine, I think with both ^ and $ you can have an underscore in there with no harm done.  For example, $100 = $_100, and _100$ = _100_$. They're redundant, but they work.

     

    I did the exact same thing as you, vinman.  I think our solution works just fine!

  • I think the WB solution is wrong.

    The task asks to allow router "destined for AS100 and its directly connected customers"

    That means to me path with 100 or 100 plus one other AS.

    The solution guide uses a regexp that gives only directly connected ASs but not AS100 routes:

     


     


    Rack1R2#sh ip bgp rege ^100(_[0-9]+)$

    BGP table version is 35, local router ID is 150.1.2.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

    *> 28.119.16.0/24   129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 28.119.17.0/24   129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 114.0.0.0        129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 115.0.0.0        129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 116.0.0.0        129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 117.0.0.0        129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 118.0.0.0        129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 119.0.0.0        129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

     

     

    I think this is the correct regexp:

     


    Rack1R2#sh ip bgp rege ^100_[0-9]*$

    BGP table version is 35, local router ID is 150.1.2.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

    *  0.0.0.0          129.1.124.4              0             0 100 i

    *>i                 129.1.17.7               0    200      0 100 i

    *> 28.119.16.0/24   129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 28.119.17.0/24   129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 114.0.0.0        129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 115.0.0.0        129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 116.0.0.0        129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 117.0.0.0        129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 118.0.0.0        129.1.124.4                            0 100 54 i

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 119.0.0.0        129.1.124.4                            0 100 54 i

       Network          Next Hop            Metric LocPrf Weight Path

    * i                 129.1.13.1               0    100      0 100 54 i

    *> 129.1.45.0/29    129.1.124.4              0             0 100 i

    * i                 129.1.13.1               0    100      0 100 i

    *> 129.1.46.0/24    129.1.124.4              0             0 100 i

    * i                 129.1.13.1               0    100      0 100 i

    *> 129.1.58.0/24    129.1.124.4                            0 100 i

    * i                 129.1.13.1               0    100      0 100 i

     

     

    HTH

     

     

     

     

     

     

     

     

     

  • I think you left a '?' out of your expression when following the SG.  The ? means '0 or 1', meaning that the entire expression [0-9]+ could either exist or not exist.  To not exist would imply that it is simply AS 100.

     

    Without the ?, the regex becomes representative of only the connected customers.

  • hi,

    Isn't the following ok for defining what as paths are selected?

    ip as-path access-list 1 permit ^100$
    ip as-path access-list 1 permit ^100_[0-9]+$

    thanks

     

  • Yup, I agree with your solution for this task. As long as the task doesn't require us to use only one line for as-path access-list :)

  • I've used ^100_([0-9]+)?$...achieving the same result.....

     

    However, the SG focusses on the Reg expression but the SG is incomplete, I've commented on another post for this task..... see

     


    2.8 Default Route 

    http://ieoc.com/forums/t/16324.aspx

     

    kr

    Josua

     

  • Hi,

       When using regex with BGP, as long as you satisfy exact task requirements, it doen't really matter which regex you use, a simpler or complicated one.

    Good luck with your studies!

  • I used ^100_[0-9]*$

     

    Sure, it involves some slop, but within the constrants of the data feed (AS path lists), it works acceptable.

  •  I used a route-map for filtering instead of a filter list.  Would this be acceptable?

    The results appear to be the same.

  • I am not sure about this task but in general it's better to use route-map instead of filter list if you have an option to do so.

     I used a route-map for filtering instead of a filter list.  Would this be acceptable?

    The results appear to be the same.

     

  • I think you should also take into account the fact that AS prepending can be used by either AS100 or the directly connected AS. To test this I manipulated some routes by adding AS'es to the BB1 routes. Testing this with the SG answer did not gave me the correct results.I configured the following:

    ip as-path access-list 3 permit ^(100_)([0-9]+)(_2)*$
    ip as-path access-list 3 permit ^(100_)+$
    !
    route-map AS100 permit 10
     match as-path 3

    My BGP table:

    Rack1R1#sh ip bgp
    BGP table version is 92, local router ID is 150.1.1.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
    *  0.0.0.0          129.1.124.4              0             0 100 i
    *>i                 129.1.17.7               0    200      0 100 i
    *> 6.6.6.0/24       129.1.124.4                            0 100 i
    *> 8.8.8.0/24       129.1.124.4                            0 100 i
    *> 28.119.16.0/24   129.1.124.4                            0 100 54 i
    *> 28.119.17.0/24   129.1.124.4                            0 100 54 i
    *> 112.0.0.0        129.1.124.4                            0 100 54 54 50 60 i
    *> 113.0.0.0        129.1.124.4                            0 100 54 50 60 i
    *> 114.0.0.0        129.1.124.4                            0 100 54 54 i
    *> 115.0.0.0        129.1.124.4                            0 100 54 i
    *> 116.0.0.0        129.1.124.4                            0 100 54 54 54 54 i
    *> 117.0.0.0        129.1.124.4                            0 100 54 i
    *> 118.0.0.0        129.1.124.4                            0 100 54 i
    *> 119.0.0.0        129.1.124.4                            0 100 54 i
    * i129.1.3.0/25     129.1.13.3               0    100      0 i
    *>                  129.1.13.3         2172416         32768 i
    * i129.1.3.128/25   129.1.13.3               0    100      0 i
       Network          Next Hop            Metric LocPrf Weight Path
    *>                  129.1.13.3         2172416         32768 i
    * i129.1.17.0/24    129.1.13.3         2172416    100      0 i
    *>                  0.0.0.0                  0         32768 i
    *> 129.1.45.0/29    129.1.124.4              0             0 100 i
    *> 129.1.46.0/24    129.1.124.4              0             0 100 i
    *> 129.1.58.0/24    129.1.124.4              2             0 100 i
    *>i205.90.31.0      129.1.23.2               0    100      0 254 ?
    *>i220.20.3.0       129.1.23.2               0    100      0 254 ?
    *>i222.22.2.0       129.1.23.2               0    100      0 254 ?

     

    Now I use the SG answer (see 114/8 and 116/8 are missing)

    Rack1R1#sh ip bgp regexp ^100(_[0-9]+)?$
    BGP table version is 92, local router ID is 150.1.1.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
    *  0.0.0.0          129.1.124.4              0             0 100 i
    *>i                 129.1.17.7               0    200      0 100 i
    *> 6.6.6.0/24       129.1.124.4                            0 100 i
    *> 8.8.8.0/24       129.1.124.4                            0 100 i
    *> 28.119.16.0/24   129.1.124.4                            0 100 54 i
    *> 28.119.17.0/24   129.1.124.4                            0 100 54 i
    *> 115.0.0.0        129.1.124.4                            0 100 54 i
    *> 117.0.0.0        129.1.124.4                            0 100 54 i
    *> 118.0.0.0        129.1.124.4                            0 100 54 i
    *> 119.0.0.0        129.1.124.4                            0 100 54 i
    *> 129.1.45.0/29    129.1.124.4              0             0 100 i
    *> 129.1.46.0/24    129.1.124.4              0             0 100 i
    *> 129.1.58.0/24    129.1.124.4              2             0 100 i

    Using my AS-path acl it all works even with prepending

    Rack1R1#sh ip bgp regexp ^(100_)([0-9]+)(_2)*$
    BGP table version is 92, local router ID is 150.1.1.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
    *> 28.119.16.0/24   129.1.124.4                            0 100 54 i
    *> 28.119.17.0/24   129.1.124.4                            0 100 54 i
    *> 114.0.0.0        129.1.124.4                            0 100 54 54 i
    *> 115.0.0.0        129.1.124.4                            0 100 54 i
    *> 116.0.0.0        129.1.124.4                            0 100 54 54 54 54 i
    *> 117.0.0.0        129.1.124.4                            0 100 54 i
    *> 118.0.0.0        129.1.124.4                            0 100 54 i
    *> 119.0.0.0        129.1.124.4                            0 100 54 i
    Rack1R1#sh ip bgp regexp ^(100_)+$            
    BGP table version is 92, local router ID is 150.1.1.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
    *  0.0.0.0          129.1.124.4              0             0 100 i
    *>i                 129.1.17.7               0    200      0 100 i
    *> 6.6.6.0/24       129.1.124.4                            0 100 i
    *> 8.8.8.0/24       129.1.124.4                            0 100 i
    *> 129.1.45.0/29    129.1.124.4              0             0 100 i
    *> 129.1.46.0/24    129.1.124.4              0             0 100 i
    *> 129.1.58.0/24    129.1.124.4              2             0 100 i

Sign In or Register to comment.