route-map简析 Route-map 可以控制路由条目,可以控制路由学不学的到路由。
如上图所示: R1(config)#int e0/0 R1(config-if)#ip add 12.12.12.1 255.255.255.0 R1(config-if)#no sh 还有四个环回口 1.1.1.1 2.2.2.2 3.3.3.3 4.4.4.4 R2(config)#int e0/0 R2(config-if)#ip add 12.12.12.2 255.255.255.0 R2(config-if)#no sh R2(config-if)#int e0/1 R2(config-if)#ip add 23.23.23.1 255.255.255.0 R2(config-if)#no sh R3(config)#int e0/1 R3(config-if)#ip add 23.23.23.2 255.255.255.0 R3(config-if)#no sh 然后在r1上运行rip R1(config)#router rip R1(config-router)#no au R1(config-router)#ver 2 R1(config-router)#net 12.12.12.0 R1(config-router)#net 1.1.1.0 R1(config-router)#net 2.2.2.0 R1(config-router)#net 3.3.3.0 R1(config-router)#net 4.4.4.0 R3上运行ospf R3(config)#router ospf 111 R3(config-router)#net 23.23.23.0 0.0.0.255 area 0 R2上 R2(config)#router rip R2(config-router)#no au R2(config-router)#ver 2 R2(config-router)#net 12.12.12.0 R2(config)#router ospf 111 R2(config-router)#net 23.23.23.0 0.0.0.255 area 0 R2(config-router)#ex 接着在r2上运行重分布 R2(config)#router ospf 111 R2(config-router)#redistribute rip subnets R2(config)#router rip R2(config-router)#redistribute ospf 111 metric 1 我们的实验关键是route-map 施行路由条目的控制 例如: 我们只让r3学习到1.1.1.1 和 2.2.2.2 步骤如下: 我们先写下acl R2(config)#access-list 1 permit 1.1.1.0 0.0.0.255 R2(config)#access-list 1 permit 2.2.2.0 0.0.0.255 只允许1网段和2网段 R2(config)#route-map AAA permit 10 /route-map 的名字是AAA permit 10意思是 指,如果下述match命令后面指定的条件成立的话,则其动作为允许。 R2(config-route-map)#match ip address 1 /1指的是acl的关键字 R2(config)#router ospf 111 R2(config-router)#redistribute rip metric 10 route-map AAA /在路由重布时,引用刚才配置route-map对重发布的路由进行过滤。 这时候我们show下r3 R3#show ip route Codes: C – connected, S – static, R – RIP, M – mobile, B – BGP D – EIGRP, EX – EIGRP external, O – OSPF, IA – OSPF inter area N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2 E1 – OSPF external type 1, E2 – OSPF external type 2 i – IS-IS, su – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2 ia – IS-IS inter area, * – candidate default, U – per-user static route o – ODR, P – periodic downloaded static route Gateway of last resort is not set 1.0.0.0/24 is subnetted, 1 subnets O E2 1.1.1.0 [110/10] via 23.23.23.1, 00:22:50, Ethernet0/1 2.0.0.0/24 is subnetted, 1 subnets O E2 2.2.2.0 [110/10] via 23.23.23.1, 00:22:50, Ethernet0/1 23.0.0.0/24 is subnetted, 1 subnets C 23.23.23.0 is directly connected, Ethernet0/1 只有1和2的网段了。
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
未经允许不得转载:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权!
路由网 »
route-map简析