Junos OS

Expand all | Collapse all

ROUTE-LIST longest match in routing policy

Jump to Best Answer
  • 1.  ROUTE-LIST longest match in routing policy

    Posted 06-21-2017 09:17

    HI everyone,


    I am trying to learn how the " order " does not matter when using Route-list in import routing policy ( assuming different prefix ).


    Please consider the following Policy:



    Our toplogy:


    R5 ( em0.200 JUN4


    R5: Cisco router, running RIP Ver2 with Juniper JUN4, it is advertsining,



    We will apply the above policy as IMPUT POLICY TO RIP on JUN4,  but before we apply the policy, routing table on JUN4 is:



    Above we can see all the RIP routes.


    Next we apply the policy " MISSY" as  an IMPORT POLICY to RIP on JUN4



    We expect only single RIP route based on IMPORT POLICY MISSY, however we do not see any RIP routes:



    If we remove the policy, we see all the rip routes:





    Based on Juniper doc, longest match term will be evaluated first which is TERM2 here but we do not see this here.


    What am i missing?


    Thanks and have a nice day!!











  • 2.  RE: ROUTE-LIST longest match in routing policy

    Posted 06-21-2017 09:33



    Policies are evaluated sequentially, i.e 1st term, 2nd, 3rd and so on if preceeding terms are not matched.

    Whether the next term is evaluated also depends on the action of a matched term. Example for accept and reject actions no further terms are evaluated, but an action of next-term does:




    In this case, once term 1 is matched routes are rejected and exits policy, term 2 is not processed.


    Hope this helps.




  • 3.  RE: ROUTE-LIST longest match in routing policy

    Posted 06-21-2017 09:54

    Thanks Ashvino!!


    This is excatly I see as well but I am confused when I read following:



    How Prefix Order Affects Route Filter Evaluation

    The order in which the prefixes are specified (from top to bottom) typically does not matter, because the policy framework software scans the route filter looking for the longest prefix during evaluation. An exception to this rule is when you use the same destination prefix multiple times in a list. In this case, the order of the prefixes is important, because the list of identical prefixes is scanned from top to bottom, and the first match type that matches the route applies.


    I am also reading a book " JUNOS ENTERPRISE ROUTING" which says the same thing but my lab does not corroborate that or I am missing something here.


    Have a nice day!!



  • 4.  RE: ROUTE-LIST longest match in routing policy
    Best Answer

    Posted 06-21-2017 10:12

    inside a "from" statement with multiple route-filter the prefix length is evaluated, but not between different terms.

    you interpreted the information wrong





  • 5.  RE: ROUTE-LIST longest match in routing policy

    Posted 06-21-2017 10:27

    Great, that was my hunch but you made it real clear.


    Much appreciated!!

  • 6.  RE: ROUTE-LIST longest match in routing policy

    Posted 06-21-2017 10:16

    I think  I am missing something:


    Terms with in a policy are evaluated in sequential orderm if a term contains multiple " route-filter" then longest match from that term will be used for matching criteria .


    Policy TEST

    term 1 from route-filter

                 from route-filter

                 then accept


    term2 from route-filter

               f then reject


    If we apply the above policy as IMPORT, a prefix will be first matched against term1 because it is listed first, with in that term, longest match is picked for comparison which route-filter which matches the prefix so it a match,


    I see the above behavior when I labbed it up.