Junos OS

 View Only
last person joined: 2 days ago 

Ask questions and share experiences about Junos OS.
  • 1.  How to insert a new community in the policy-statement

    Posted 06-26-2019 08:03

    Hello Guys,

    I have an existing policy (sample below) and need to add the new communities to it.

     

    In order to avoid the re ordering in the policy-statment with every new provisioning , is there any option to use the "insert" command. I like to add the new community added before the COMMUNITY-LAST statement so can add all new communites before it.

     

     

    Thanks



    set policy-options community COMMUNITY-AAAA members target:11111:99999
    set policy-options community COMMUNITY-LAST members target:99999:99999

    set policy-options policy-statement MY-COMMUNITY term a from protocol bgp
    set policy-options policy-statement MY-COMMUNITY term a from community COMMUNITY-AAAA
    set policy-options policy-statement MY-COMMUNITY term a from community COMMUNITY-LAST
    set policy-options policy-statement MY-COMMUNITY term a then accept
    set policy-options policy-statement MY-COMMUNITY term b then reject


    #insert
    #policy-options


  • 2.  RE: How to insert a new community in the policy-statement
    Best Answer

     
    Posted 06-26-2019 08:11
    root@test# show policy-options 
    policy-statement MY-COMMUNITY {
        term a {
            from {
                protocol bgp;
                community [ COMMUNITY-AAAA COMMUNITY-LAST ];
            }
            then accept;
        }
        term b {
            then reject;
        }
    }
    
    {master:0}[edit]
    root@test# set policy-options policy-statement MY-COMMUNITY term a from community COMMUNITY-BBBB    
    
    {master:0}[edit]
    root@test# show policy-options                                                                      
    policy-statement MY-COMMUNITY {
        term a {
            from {
                protocol bgp;
                community [ COMMUNITY-AAAA COMMUNITY-LAST COMMUNITY-BBBB ];
            }
            then accept;
        }
        term b {
            then reject;
        }
    }
    
    {master:0}[edit]
    root@test# insert policy-options policy-statement MY-COMMUNITY term a from community COMMUNITY-BBBB before COMMUNITY-LAST 
    
    {master:0}[edit]
    root@test# show policy-options                                                                                               
    policy-statement MY-COMMUNITY {
        term a {
            from {
                protocol bgp;
                community [ COMMUNITY-AAAA COMMUNITY-BBBB COMMUNITY-LAST ];
            }
            then accept;
        }
        term b {
            then reject;
        }
    }
    


  • 3.  RE: How to insert a new community in the policy-statement

    Posted 06-26-2019 10:48

    Hi,

     

    While this can be acheived via below command, I was wondering on what usecase do you require this? From what i understand policy "MY-COMMUNITY" will evaluate all the communities in an OR fashion, so how does the order matter? I can certainly understand if another set of policies are called via a policy the order will matter, but what we can acheive with reordering the "Communities"?

     

    "insert policy-options policy-statement <x> from community X before Y"

     

    thanks

    Nischal



  • 4.  RE: How to insert a new community in the policy-statement

    Posted 06-26-2019 12:35

    Thanks smicker and Nishal.  It was more of my own understanding of the insert feature and for the operational sanity check.

     

    Thank again for the quick solve.