最近在学习CCNP的相关课程和知识要点,总结出来的一些东西未必是正确的,不过先发表出来,共大家参考和讨论。先说说使用route-map控制路由重分发的方法、组网和配置,以4个路由器组成一个链式网络。 至于这些命令是在什么模式下打出来的,有基础的应该都能看出来的,就不要纠结于这些命令是在全局模式还是在路由模式抑或是在接口模式下打出来的。废话不多说了,进入正题。
以上是拓扑图,下面上配置以及简单的介绍。 有时候我们想控制路由协议重分发时哪些路由条目应该通告,哪些路由条目不应该通告。这样做可能是为了保密,也可能是为了别的目地,管他呢,反正有些人就是有一些奇奇怪怪的需求。而要达到这个目的的有两种工具,通过分发列表控制哪些路由条目应该被重分发,哪些不应该被重分发。而另一种工具为路由映射表,而我今天讲的就是利用路由映射表来经行路由重分发控制。 简单介绍下什么是路由映射表。路由映射表是一种逻辑化的语言,就像程序语言中的if-then-else,满足某种条件就执行某项动作。而路由映射表的功能就太强大了,像我前面做的pbr用到了路由映射表,而做bgp路径控制更要用到路由映射表,而今天讲控制重分发又用到了。 废话不多说了,先讲讲拓扑结构。4台路由器,其中r1和r4运行ripv2,在r1上有4个环回接口。r2为asbr路由器,分别运行着ripv2和ospf,r3也为ospf。 r4: in e1/0 ip add 192.168.1.1 255.255.255.0 no sh in loop 1 ip add 4.4.4.4 255.0.0.0 router rip version 2 net 192.168.1.0 net 4.0.0.0 r1: in e1/1 ip add 192.168.1.2 255.255.255.0 no sh in e1/0 ip add 192.168.2.1 255.255.255.0 no sh in loop 1 ip add 172.16.0.1 255.255.255.0 in loop 2 ip add 172.16.1.1 255.255.255.0 in loop 3 ip add 172.16.2.1 255.255.255.0 in loop 4 ip add 172.16.3.1 255.255.255.0 router rip version 2 no au net 192.168.1.0 net 192.168.2.0 net 172.16.0.0 r2: in e1/1 ip add 192.168.2.2 255.255.255.0 no sh in e1/0 ip add 192.168.3.1 255.255.255.0 no sh router rip version 2 net 192.168.2.0 redistribute ospf 1 metric 2 重分发ospf路由到rip router ospf 1 net 192.168.3.1 0.0.0.0 a 0 redistribute rip route-map test subnets 这条命令引用路由映射表test将rip重分发到ospf
access-list 1 permit 172.16.1.0 0.0.0.255 access-list 1 permit 172.16.2.0 0.0.0.255 这3条acl控制匹配哪些路由条目,允许的将会被重分发 access-list 1 permit 192.168.1.0 0.0.0.255
route-map test permit 10 定义路由映射表名字为test,采取的行为为允许 match ip add 1 匹配的acl为access-list 1 set metric-type type-1 行为为将分发类型改为1类 r3: in e1/1 http://www.luyouqiwang.com/14427/ ip add 192.168.3.2 255.255.255.0 no sh ip ospf 1 a 0
看看效果,在r3上我们只重分发了匹配acl1的3条路由条目,而且把分发类型改为了1类,而默认是2类。 R3#show ip rou 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
172.16.0.0/24 is subnetted, 2 subnets O E1 172.16.1.0 [110/30] via 192.168.3.1, 00:32:06, Ethernet1/1 O E1 172.16.2.0 [110/30] via 192.168.3.1, 00:32:06, Ethernet1/1 O E1 192.168.1.0/24 [110/30] via 192.168.3.1, 00:32:06, Ethernet1/1 C 192.168.3.0/24 is directly connected, Ethernet1/1 而分别ping也验证了确实达到了控制重分发条目的目的 R3#ping 192.168.1.1
Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 12/57/100 ms R3#ping 172.16.3.1
Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.3.1, timeout is 2 seconds: ..... Success rate is 0 percent (0/5) R3#ping 172.16.1.1
Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 16/45/88 ms 至于不运用路由映射表进行重分发控制的我就不多说了。 |
不良信息举报Q:2000617|Archiver|ROS软路由论坛 ROSABC.com 网络方案网络工程交流
GMT+8, 2025-11-13 05:41 , Processed in 0.032290 second(s), 15 queries .
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.