Routing

Expand all | Collapse all

What does this AS path reg-ex match ?

Jump to Best Answer
  • 1.  What does this AS path reg-ex match ?

    Posted 06-15-2019 03:56

    why does 

     

    root@srx1# run show route aspath-regex "1912 1620 5555 . (2222|3333) +1111"

     

    Match this route 

     

     

    inet.0: 551 destinations, 559 routes (512 active, 0 holddown, 40 hidden)
    + = Active Route, - = Last Active, * = Both

    44.33.0.0/16 *[BGP/170] 00:12:13, localpref 150
    AS path: 1912 1620 5555 4444 3333 2222 1111 I, validation-state: unverified
    > to 172.16.101.1 via ge-0/0/4.101

    H1.inet.0: 1 destinations, 1 routes (1 active, 0 holddown, 0 hidden)

    H3.inet.0: 1 destinations, 1 routes (1 active, 0 holddown, 0 hidden)

    inet6.0: 85 destinations, 94 routes (85 active, 0 holddown, 0 hidden)

    [edit]
    root@srx1#

     

     

    from what I can see working right to left the match should fail on 4444

     

    +1111 matches 1111

    (2222|3333) matches 2222

    .                   matches 3333

    4444 does not match 5555

     

    so why does it match ? so confused.  Any assistance appreciated, 

     



  • 2.  RE: What does this AS path reg-ex match ?

     
    Posted 06-15-2019 04:29

    "1912 1620 5555 . (2222|3333) +1111"

    Starts with: 1912 1620 5555

    Also Contains either of these two: (2222|3333)

    And contains: 1111

     



  • 3.  RE: What does this AS path reg-ex match ?
    Best Answer

    Posted 06-16-2019 23:10

    Hi !

    The blanks between the ) and  the + are quite confusing, but they are neglected

    In my opinion the + belongs to the previous term (2222|3333)

    so the system read (2222|3333)+ 1111

    which means one ore more of 2222 or 3333 or mixed and then the 1111

     

    and then the result is okay

     

    regards

     

    alexander



  • 4.  RE: What does this AS path reg-ex match ?

    Posted 06-17-2019 00:22

    Thankyou


    Regards


    Simon

     



  • 5.  RE: What does this AS path reg-ex match ?

     
    Posted 06-16-2019 23:35

    Hi Simon,

     

    Well  please find below the meaning for this regular expression,

     

    root@srx1# run show route aspath-regex "1912 1620 5555 . (2222|3333) +1111"

     

    What it means is the AS-PATH shouold begin with "1912 1620 5555"

    then there is dot(.) wildcard which means any single ASN, in your case it matches 4444

    after that there is parenthesis () which means to select either of the value 2222 or 3333

    then there is + wildcard which means one or more times repetition of the preceding expression, which in this case is (2222 or 3333) therefore it matches 3333 2222.

    and lastly it should end with 1111.

     

    Adding all 1912 1620 5555 + 4444 + 3333 2222 + 1111 equals to the matching as-path set

    AS path: 1912 1620 5555 4444 3333 2222 1111 I, validation-state: unverified

     

    Kindly refer followinf document for details,

    https://www.juniper.net/documentation/en_US/junos/topics/usage-guidelines/policy-configuring-as-path-regular-expressions-to-use-as-routing-policy-match-conditions.html

     

    Regards,

    Ankur

    JNCIE*3 (SP|DC|ENT)



  • 6.  RE: What does this AS path reg-ex match ?

    Posted 06-16-2019 23:45

    Hi,

    Although it's already answered above, just wanted to add that just as in conventional regular expressions all the quantifiers (i.e. '*', '+', '?', {n}, etc.) always go AFTER the token. I.e 'a+b' will match 'ab', 'aab', 'aaab', etc. but not 'abb'.

    In case of conventional regular expression 'a +b' will match 'a b', 'a  b', 'a   b', 'a     b', etc. (i.e. 'a' followed by one or more spaces and then 'b'), but in case of ASP regex the spaces are ignored as pointed out above.



  • 7.  RE: What does this AS path reg-ex match ?

    Posted 06-17-2019 00:04

    thanks so much, so the key thing I was missing was that the + related to the preceeding expression,  I knew my understading was off somewhere  here thanks so much for your assitance