05-12-2020 12:25 AM
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
Solved! Go to Solution.
05-14-2020 01:04 AM
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
05-12-2020 05:50 AM
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.
05-12-2020 05:54 AM
05-12-2020 08:19 AM
05-12-2020 07:53 AM - edited 05-12-2020 07:55 AM
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
05-12-2020 08:14 AM
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
05-12-2020 08:15 AM
So I wana ask is the similar criteria applies to community lists
@usmansa1 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
@usmansa1 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
05-13-2020 07:22 AM - edited 05-13-2020 07:24 AM
Hello @usmansa1 ,
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
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
05-13-2020 06:11 PM
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
|
|
|
|
\/
05-14-2020 01:04 AM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide