I’am trying to redistribute specific routes to ospf matching a community-list. This doesn’t work as expected, as when I try to match a community list in route-map, it effectively evaluates as a true regardless of a content.
For example when I try to exclude a set of prefix with the community 65001:1111 - other prefixes get excluded too (for example, 8.8.7.5/32 with comm 65001:2222)
set policy community-list O2B-IMPORTED rule 10 action ‘permit’
set policy community-list O2B-IMPORTED rule 10 regex ‘65001:1111’set policy route-map RMAP_B2O rule 10 action ‘deny’
set policy route-map RMAP_B2O rule 10 match community community-list ‘O2B-IMPORTED’
set policy route-map RMAP_B2O rule 20 action ‘permit’
set policy route-map RMAP_B2O rule 20 set tag ‘2222’
set protocols ospf redistribute bgp route-map ‘RMAP_B2O’
show ip bgp community-list and route-map evaluations outputs are as expected:
show ip bgp community-list O2B-IMPORTED
BGP table version is 28, local router ID is 10.222.255.120, vrf id 0
Default local pref 100, local AS 65001
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop’s vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not foundNetwork Next Hop Metric LocPrf Weight Path
- i10.2.128.0/22 10.222.255.110 20 100 0 ?
*> 10.222.252.253 20 32768 ?- i10.222.252.96/28 10.222.255.110 20 100 0 ?
*> 10.222.252.253 20 32768 ?- i172.16.19.0/24 10.222.255.110 20 100 0 ?
*> 10.222.252.253 20 32768 ?- i172.16.33.0/24 10.222.255.110 20 100 0 ?
*> 10.222.252.253 20 32768 ?- i172.16.55.0/24 10.222.255.110 20 100 0 ?
*> 10.222.252.253 20 32768 ?- i172.16.56.0/21 10.222.255.110 20 100 0 ?
*> 10.222.252.253 20 32768 ?show ip bgp route-map RMAP_B2O
BGP table version is 28, local router ID is 10.222.255.120, vrf id 0
Default local pref 100, local AS 65001
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop’s vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not foundNetwork Next Hop Metric LocPrf Weight Path
*>i1.1.1.10/32 10.222.255.110 0 100 0 i
*> 2.2.2.10/32 0.0.0.0 0 32768 i
*>i9.8.7.5/32 10.222.255.110 0 100 0 i
*> 9.8.7.6/32 0.0.0.0 0 32768 iDisplayed 4 routes and 16 total paths
BGP community tags are OK:
show ip bgp ipv4 unic 9.8.7.5
BGP routing table entry for 9.8.7.5/32, version 28
Paths: (1 available, best #1, table default)
Not advertised to any peer
Local
10.222.255.110 (metric 1) from 10.222.255.110 (10.222.255.110)
Origin IGP, metric 0, localpref 100, valid, internal, best (First path received)
Community: 65001:2222
Last update: Wed Apr 19 09:25:19 2023
Despite that it won’t result in proper redistribution to OSPF:
show ip ospf datab
OSPF Router with ID (10.222.255.120) Router Link States (Area 0.0.0.100)
Link ID ADV Router Age Seq# CkSum Link count
10.222.253.1 10.222.253.1 1605 0x8000003d 0xacfc 2
10.222.255.110 10.222.255.110 818 0x800000ad 0x0fd2 6
10.222.255.120 10.222.255.120 802 0x80000023 0xb6bf 6AS External Link States
Link ID ADV Router Age Seq# CkSum Route
10.2.128.0 10.222.253.1 1165 0x8000002d 0x4382 E2 10.2.128.0/22 [0x457]
10.222.252.96 10.222.253.1 1145 0x8000002d 0x8097 E2 10.222.252.96/28 [0x457]
172.16.19.0 10.222.253.1 1165 0x8000002d 0x1b64 E2 172.16.19.0/24 [0x457]
172.16.33.0 10.222.253.1 1215 0x8000002d 0x80f0 E2 172.16.33.0/24 [0x457]
172.16.55.0 10.222.253.1 1275 0x8000002d 0x8dcd E2 172.16.55.0/24 [0x457]
172.16.56.0 10.222.253.1 1175 0x8000002d 0x5f02 E2 172.16.56.0/21 [0x457]
If I remove a route-map entry 10 matching the community-list - routes are redistributed normally:
run show ip ospf datab
OSPF Router with ID (10.222.255.120)
Router Link States (Area 0.0.0.100)
Link ID ADV Router Age Seq# CkSum Link count
10.222.253.1 10.222.253.1 140 0x8000003e 0xaafd 2
10.222.255.110 10.222.255.110 1044 0x800000ad 0x0fd2 6
10.222.255.120 10.222.255.120 1029 0x80000023 0xb6bf 6
AS External Link States
Link ID ADV Router Age Seq# CkSum Route
1.1.1.10 10.222.255.120 56 0x80000001 0xcfc9 E2 1.1.1.10/32 [0x8ae]
9.8.7.5 10.222.255.120 56 0x80000001 0x0386 E2 9.8.7.5/32 [0x8ae]
10.2.128.0 10.222.253.1 1391 0x8000002d 0x4382 E2 10.2.128.0/22 [0x457]
10.222.252.96 10.222.253.1 1371 0x8000002d 0x8097 E2 10.222.252.96/28 [0x457]
172.16.19.0 10.222.253.1 1391 0x8000002d 0x1b64 E2 172.16.19.0/24 [0x457]
172.16.33.0 10.222.253.1 1441 0x8000002d 0x80f0 E2 172.16.33.0/24 [0x457]
172.16.55.0 10.222.253.1 1501 0x8000002d 0x8dcd E2 172.16.55.0/24 [0x457]
172.16.56.0 10.222.253.1 1401 0x8000002d 0x5f02 E2 172.16.56.0/21 [0x457]