cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
385
Views
10
Helpful
9
Replies
Highlighted

Match statement behavior in Route maps ?

Hi All,

 

I am little confused about the behavior of the match statement in the route maps. Here is the route map mentioned below:- 

!
route-map AS65012-OUT permit 10
match community AS65012_PREPEND_ONCE PREPEND_ONCE (Match Statement # 1)
match policy-list AS65012_EXPORT ((Match Statement # 2)
set as-path prepend AS65014
!
#
ip policy-list AS65012_EXPORT permit
match community 214
#
ip community-list 214 permit 65012:2013
ip community-list 214 permit 65012:2018
#

ip community-list standard AS65012_PREPEND_ONCE permit 65012:2015
ip community-list standard PREPEND_ONCE permit 65012:2016

#

 

In route map statement 10 there are two match statements. First statement includes two communities to match 

i) AS65012_PREPEND_ONCE

ii) GENERAL_PREPEND_ONCE

The second statement includes the policy list which consist of multiple communities. 

My first question is this how the communities are matched in the route map first statement. Does AS65012_PREPEND_ONCE and GENERAL_PREPEND_ONCE both should be matched to full fill the condition the first statement or any one match is enough. 

My second question is how the statements are matched in the route maps. Does only first statement is required to be matched or both statements are required to be matched in other words is it logical OR or AND between match statements when both statements involve the BGP communities. Thanks 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Hello

Interpreting what @Giuseppe Larosa  has found it would seen it the logic is:

route-map AS65012-OUT <----match AND within route-map
match community AS65012_PREPEND_ONCE PREPEND_ONCE <----match OR within community
match policy-list AS65012_EXPORT <--match OR within list



kind regards
Paul

Please rate and mark posts accordingly if you have found any of the information provided useful.
It will hopefully assist others with similar issues in the future

View solution in original post

9 REPLIES 9
Highlighted

If the end goal is to prepend the same number of times for each community you could do something similar to the following:

 

ip community-list standard 214 permit 65012:2016

ip community-list standard 214 permit 65012:2017

!

route-map PREPEND permit 10

match community 214

set as-path prepend 65014

 

If you want to break out your prepends based on the community in question you could create a separate entry per community within the same route-map then assign it to the outbound advertisements.

Highlighted

Further reading: https://community.cisco.com/t5/switching/route-map-and-or-logical-algorithm/td-p/1980980 provides some good insight into your questions regarding AND/OR matchings.
Highlighted

It is already applied steph so that's why I am asking. Please check my reply on the same post to Paul that why it is causing confusion to me.
Highlighted
VIP Mentor

Hello
The route-map will be read for both match statements only, So if an match isnt found for either match statements then the set command isnt applicable so the logic is:

logical AND
Route-map xx
match xx
match yy

logical OR
Route-map xx
match XX  YY



kind regards
Paul

Please rate and mark posts accordingly if you have found any of the information provided useful.
It will hopefully assist others with similar issues in the future
Highlighted

Thanks Paul but I read some where that if similar things are matched then Cisco ios silently Or the criteria e.g incase of ACL if there are two ACL in different match statements then it will not AND ios makes Or decision


@paul driver wrote:

Hello
The route-map will be read for both match statements only, So if an match isnt found for either match statements then the set command isnt applicable so the logic is:

logical AND
Route-map xx
match xx
match yy

logical OR
Route-map xx
match XX  YY


 

Highlighted

So I wana ask is the similar criteria applies to community lists


@Muhammad Usman Sarwar wrote:

Thanks Paul but I read some where that if similar things are matched then Cisco ios silently Or the criteria e.g incase of ACL if there are two ACL in different match statements then it will not AND ios makes Or decision


@paul driver wrote:

Hello
The route-map will be read for both match statements only, So if an match isnt found for either match statements then the set command isnt applicable so the logic is:

logical AND
Route-map xx
match xx
match yy

logical OR
Route-map xx
match XX  YY


 



@Muhammad Usman Sarwar wrote:

Thanks Paul but I read some where that if similar things are matched then Cisco ios silently Or the criteria e.g incase of ACL if there are two ACL in different match statements then it will not AND ios makes Or decision


@paul driver wrote:

Hello
The route-map will be read for both match statements only, So if an match isnt found for either match statements then the set command isnt applicable so the logic is:

logical AND
Route-map xx
match xx
match yy

logical OR
Route-map xx
match XX  YY


 


 

Highlighted

Hello @Muhammad Usman Sarwar ,

I have looked for the policy-list command in an attempt to understand what can happen in the route-map listed in your initial post.

I have found the following in the BGP command reference

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/iproute_bgp/command/irg-cr-book/bgp-m1.html#wp4266747010

 

It says that policy-lists can be used to create different logic OR or AND and that they can be combined with standard match like in your route-map example.

For the BGP community attribute we must remember that multiple BGP communities values can be associated to a prefix.

For a standard BGP community list to match is enough that one of the BGP community values of the route is permitted by the community list ACL.

This allows to have a match also in case of a logical AND like in your route-map.

 

You have a logical OR between the two standard community-list that are matched by the match community command.

There is then a logical AND with the match policy-list that invokes the third community-list

 

A match of both match statements is possible for BGP prefixes NLRIs that have associated multiple BGP community values,  with one value mathing the first community-list OR The second community list, and another BGP community value matching one of the two values listed in the community-list invoked by the policy-list.

 

Hope to help

Giuseppe

 

 

 

Highlighted

So it means that in my route map the community list in a single statement are logical OR and the second match statement is logical AND with the first match statement. So if we draw in the arrow form it is like below. 

---------------- OR -------------->

 |

 |

 |

 |

AND

 |

 |

 |

 |

 \/

Highlighted

Hello

Interpreting what @Giuseppe Larosa  has found it would seen it the logic is:

route-map AS65012-OUT <----match AND within route-map
match community AS65012_PREPEND_ONCE PREPEND_ONCE <----match OR within community
match policy-list AS65012_EXPORT <--match OR within list



kind regards
Paul

Please rate and mark posts accordingly if you have found any of the information provided useful.
It will hopefully assist others with similar issues in the future

View solution in original post

Content for Community-Ad