Routing

Expand all | Collapse all

Matching against multiple named communities in square brackets

Jump to Best Answer
  • 1.  Matching against multiple named communities in square brackets

    Posted 10-22-2019 10:53

    Hi All, I have a question regarding using named communities in square brackets: If I have a policy like the one below:

     

    [edit policy-options]

    + community BREAD members 3000:100;

    + community BUTTER members 3000:200;

     

    [edit policy-options policy-statement TEST]

    + term match-community {

    + from {

    + protocol bgp;

    + community [ BREAD BUTTER ];

    + }

    + then accept;

    + }

    + term reject {

    + then reject;

    + }

     

    Would it mean that a route would have to have BOTH the BREAD and BUTTER communities to be accepted by this policy, or would it behave the same as the policy below where a route would only need to have either the BREAD community or the BUTTER community in order to be accepted by the policy:

     

    [edit policy-options]

    + community BREAD members 3000:100;

    + community BUTTER members 3000:200;

     

    [edit policy-options policy-statement TEST]

    + term match-community {

    + from {

    + protocol bgp;

    + community BREAD;

    + community BUTTER;

    + }

    + then accept;

    + }

    + term reject {

    + then reject;

    + }

     

    i.e. does putting NAMED communities together in square brackets make a logical AND or a logical OR?

     

    N.B: I'm aware that I could create a community called BREADBUTTER like the below:

     

    [edit policy-options]

    + community BREADBUTTER members [ 3000:100 3000:200 ]

     

    then make a policy like the below which would mean that any route would have to have BOTH communities in order to be accepted by the policy:

     

    [edit policy-options policy-statement TEST]

    + term match-community {

    + from {

    + protocol bgp;

    + community BREADBUTTER;

    + }

    + then accept;

    + }

    + term reject {

    + then reject;

    + }

     

     

    TIA



  • 2.  RE: Matching against multiple named communities in square brackets
    Best Answer

     
    Posted 10-22-2019 12:12

    Hi,

    If you have multiple communities it is a logcial OR operation. Below link provides more details - 

     

    https://www.juniper.net/documentation/en_US/junos/topics/concept/policy-bgp-communities-extended-communities-evaluation-in-routing-policy-match-conditions.html

     

    Snippet from the link - 

    Including BGP Communities and Extended Communities in Routing Policy Match Conditions

    To include a BGP community or extended community in a routing policy match condition, include the community condition in the from statement of a policy term:

    content_copyzoom_out_map
    from {
    community [ names ];
    }

    Additionally, you can explicitly exclude BGP community information with a static route by using the none option. Include this option when configuring an individual route in the route portion to override a community option specified in the defaults portion.

    You can include the names of multiple communities in the community match condition. If you do this, only one community needs to match for a match to occur (matching is effectively a logical OR operation)

     

     

    *** Please mark reply as solution if it resolves your query so others can benefit from the post



  • 3.  RE: Matching against multiple named communities in square brackets

    Posted 10-22-2019 13:53

    Many thanks.

     

    So, just to confirm;

     

    this:

     

    + from {

    + community [ BREAD BUTTER ];

    + }

    + then accept;

     

     

    Is the same as this :

     

    + from {

    + community BREAD;

    + community BUTTER;

    + }

    + then accept;

     

     

    Correct?

     



  • 4.  RE: Matching against multiple named communities in square brackets

     
    Posted 10-22-2019 16:21

    Hi,

    Yes, correct.



  • 5.  RE: Matching against multiple named communities in square brackets

     
    Posted 10-23-2019 06:17

    Hello,

    Glad this was helpful. However, can you please mark the original response as the solution so people can find it faster. I believe you marked your follow-up question/reply as the solution. 

    Thanks,

    Mayank Shah



  • 6.  RE: Matching against multiple named communities in square brackets

    Posted 10-23-2019 07:31
    Done! Many thanks again.