拓扑


目标
- 修改192.168.x.x 路由条目的 weight
- 过滤掉来自AS65300 的路由条目
- 注意,1个Neighbor 只能加载1个route-map,加载多个的话,会覆盖前面的。所以需要写1个route-map,包含不同的rule
- 通过 redistribute connect 宣告网络
ip as-path access-list 1 permit _65300$
!
ip prefix-list PRE_192_168 seq 5 permit 192.168.0.0/16 le 32
!
route-map RM_192_168 permit 10
match ip address prefix-list PRE_192_168
set weight 1111
!
route-map RM_192_168 deny 20
match as-path 1
!
route-map RM_192_168 permit 30
!
- 注意看,来自65300 的 100.64.3.0 路由条目没有了。但是192.168.3.3 还在,因为Route-map 内部也是逐次匹配的,只要有1个rule 匹配到就执行并退出,不会再匹配后续的rule —— 192.168.3.3 是先匹配到了set weight

- 我们调整route-map,让过滤65300的rule 调整到前面,再来查看结果 —— 可以看到来自65300的路由条目都消失了, 只有192.168.2.2 的路由被设置了Weight

R1(config-route-map)#do show route-map
route-map RM_192_168, deny, sequence 10
Match clauses:
as-path (as-path filter): 1
Set clauses:
Policy routing matches: 0 packets, 0 bytes
route-map RM_192_168, permit, sequence 20
Match clauses:
ip address prefix-lists: PRE_192_168
Set clauses:
weight 1114
Policy routing matches: 0 packets, 0 bytes
route-map RM_192_168, permit, sequence 30
Match clauses:
Set clauses:
Policy routing matches: 0 packets, 0 bytes
拓展
- 对来自AS 65300 的 192.168.x.x 路由条目,设置Weight 1111
ip as-path access-list 1 permit _65300$
!
ip prefix-list PRE_192_168 seq 5 permit 192.168.0.0/16 le 32
ipv6 ioam timestamp
!
route-map RM_192_168 permit 10
match ip address prefix-list PRE_192_168
match as-path 1
set weight 1111
!
route-map RM_192_168 permit 20
!
router bgp 65100
neighbor 10.12.1.2 route-map RM_192_168 in
!
