拓扑图:
没配置分发列表前:
R2:
router ospf 1
redistribute connected metric 10 subnets
redistribute rip metric 30 subnets
network 192.168.23.0 0.0.0.255 area 0
!
router rip
version 2
redistribute connected metric 2
redistribute ospf 1 metric 4
network 192.168.12.0
no auto-summary
查看各路由器的路由表:
r1#sh ip rou
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/24 is subnetted, 1 subnets
R 2.2.2.0 [120/2] via 192.168.12.2, 00:00:17, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
C 10.10.10.0 is directly connected, Loopback1
R 192.168.23.0/24 [120/2] via 192.168.12.2, 00:00:17, Serial0/0
r1#
r2#sh ip rou
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/1] via 192.168.12.1, 00:00:11, Serial0/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 1 subnets
R 10.10.10.0 [120/1] via 192.168.12.1, 00:00:11, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/1
r2#
r3#sh ip rou
O E2 192.168.12.0/24 [110/10] via 192.168.23.1, 00:00:22, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/30] via 192.168.23.1, 00:00:22, Serial0/0
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [110/10] via 192.168.23.1, 00:00:22, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
O E2 10.10.10.0 [110/30] via 192.168.23.1, 00:00:09, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/0r3#
可以看到各路由器都学习到了全网的路由!
下面配置分发列表:
R2:
access-list 1 permit 1.1.1.0 0.0.0.255
router ospf 1
distribute-list 1 out rip //配置分发列表,关联ACL序号1,应用在出接口,协议为RIP;这里的RIP是指重发布的来源为RIP协议(过渡从RIP网络重发布过来的,其它路由协议的路由不受影响,如下,R2的直连路由2.2.2.2/24没有被过渡掉)
S注意:distribute-list 1 后面如何要加协议的话只能在OUT方向,IN方向无此功能!!!
查看R3的路由表:
r3#sh ip rou
O E2 192.168.12.0/24 [110/10] via 192.168.23.1, 00:01:03, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/30] via 192.168.23.1, 00:01:03, Serial0/0
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [110/10] via 192.168.23.1, 00:01:03, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/0
r3#
可以看出R3只学习到了RIP网络的1.1.1.1/24,那为什么2.2.2.0/24还在呢?因为它是R2的直连路由而不是RIP网络的路由!!!
本文转自810105851 51CTO博客,原文链接http://blog.51cto.com/4708948/1131442:,如需转载请自行联系原作者