RIP和OSPF双点双向重发布_综合实验
原创
©著作权归作者所有:来自51CTO博客作者810105851的原创作品,请联系作者获取转载授权,否则将追究法律责任
拓扑图:
配置任务:
1.
配置R3,R5双点双向重分发,使R4学到的RIP网络负载均衡。
2.
配置R4学习到1.1.1.1/24的路由优先走R3。
配置详情:
如上的配置任务中1有2种配置方法:
1.
通过分发列表来实现;
2.
通过修改AD值来实现;
下面分别讲解2种配置方法:
没有配置2种方法前,各路由器的路由表:
配置参数:
R3:
router ospf 1
redistribute rip metric 40 subnets
network 192.168.34.0 0.0.0.255 area 0
router rip
version 2
redistribute ospf 1 metric 5
network 192.168.23.0
no
auto-summary
R5:
router ospf 1
redistribute rip metric 40 subnets
network 192.168.45.0 0.0.0.255 area 0
router rip
version 2
redistribute ospf 1 metric 5
network 192.168.25.0
no
auto-summary
R1:
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, Loopback1
R
192.168.45.0/24 [120/6] via 192.168.12.2, 00:00:06, Serial0/0
R
192.168.25.0/24 [120/1] via 192.168.12.2, 00:00:06, Serial0/0
R
192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:06, Serial0/0
11.0.0.0/24 is subnetted, 1 subnets
C
11.11.11.0 is directly connected, Loopback11
R
192.168.34.0/24 [120/6] via 192.168.12.2, 00:00:06, Serial0/0
r1#
R2:
r2#sh ip rou
C
192.168.12.0/24 is directly connected, Serial0/2
1.0.0.0/24 is subnetted, 1 subnets
R
1.1.1.0 [120/1] via 192.168.12.1, 00:00:03, Serial0/2
R
192.168.45.0/24 [120/5] via 192.168.25.1, 00:00:00, Serial0/0
[120/5] via 192.168.23.1,
00:00:15, Serial0/1
C
192.168.25.0/24 is directly connected, Serial0/0
C
192.168.23.0/24 is directly connected, Serial0/1
11.0.0.0/24 is subnetted, 1 subnets
R
11.11.11.0 [120/1] via 192.168.12.1, 00:00:03, Serial0/2
R
192.168.34.0/24 [120/5] via 192.168.25.1, 00:00:00, Serial0/0
[120/5] via 192.168.23.1,
00:00:16, Serial0/1
r2#
R3:
r3#sh ip rou
R
192.168.12.0/24 [120/1] via 192.168.23.2, 00:00:04, Serial0/1
1.0.0.0/24 is subnetted, 1 subnets
R
1.1.1.0 [120/2] via 192.168.23.2, 00:00:04, Serial0/1
O
192.168.45.0/24 [110/128] via 192.168.34.2, 00:37:41, Serial0/0
O E2 192.168.25.0/24 [110/40] via
192.168.34.2, 00:37:41, Serial0/0
C
192.168.23.0/24 is directly connected, Serial0/1
11.0.0.0/24 is subnetted, 1 subnets
R
11.11.11.0 [120/2] via 192.168.23.2, 00:00:04, Serial0/1
C
192.168.34.0/24 is directly connected, Serial0/0
r3#
R4:
r4#sh ip rou
O E2 192.168.12.0/24 [110/40] via
192.168.34.1, 00:38:00, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2
1.1.1.0 [110/40] via 192.168.34.1, 00:38:00, Serial0/0
C
192.168.45.0/24 is directly connected, Serial0/1
O E2 192.168.25.0/24 [110/40] via
192.168.45.1, 00:38:00, Serial0/1
O E2 192.168.23.0/24 [110/40] via
192.168.34.1, 00:38:00, Serial0/0
11.0.0.0/24 is subnetted, 1 subnets
O E2
11.11.11.0 [110/40] via 192.168.34.1, 00:38:00, Serial0/0
C 192.168.34.0/24
is directly connected, Serial0/0
r4#
可以看到R4是通过R3学习到RIP网络的路由的!!!
R5:
r5#sh ip rou
O E2 192.168.12.0/24 [110/40] via
192.168.45.2, 00:38:19, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2
1.1.1.0 [110/40] via 192.168.45.2, 00:38:19, Serial0/0
C
192.168.45.0/24 is directly connected, Serial0/0
C
192.168.25.0/24 is directly connected, Serial0/1
O E2 192.168.23.0/24 [110/40] via
192.168.45.2, 00:38:19, Serial0/0
11.0.0.0/24 is subnetted, 1 subnets
O E2
11.11.11.0 [110/40] via 192.168.45.2, 00:38:19, Serial0/0
O
192.168.34.0/24 [110/128] via 192.168.45.2, 00:38:19, Serial0/0
r5#
可以看到R5是通过OSPF来学习RIP网络的路由的,这样产生了次优路由,解决方法如下:
方法一:
R3:
r3(config)#acc 1 de 1.1.1.0
r3(config)#acc 1 de 11.11.11.0
r3(config)#acc 1 per an
r3(config)#router os 1
r3(config-router)#distribute-list 1 in s0/0
R5:
r5(config)#acc 1 de 1.1.1.0
r5(config)#acc 1 de 11.11.11.0
r5(config)#acc 1 per an
r5(config)#router os 1
r5(config-router)#distribute-list 1 in s0/0
配置完这些R5的路由表就可以学到最优的路由了,R4学习到的RIP网络的路由也会实现负载均衡!!!效果如下:
R5:
r5#SH IP ROU
O E2 192.168.12.0/24 [110/40] via
192.168.45.2, 00:03:04, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
R
1.1.1.0 [120/2] via 192.168.25.2, 00:00:09, Serial0/1
C
192.168.45.0/24 is directly connected, Serial0/0
C
192.168.25.0/24 is directly connected, Serial0/1
O E2 192.168.23.0/24 [110/40] via
192.168.45.2, 00:03:04, Serial0/0
11.0.0.0/24 is subnetted, 1 subnets
R
11.11.11.0 [120/2] via 192.168.25.2, 00:00:09, Serial0/1
O
192.168.34.0/24 [110/128] via 192.168.45.2, 00:03:04, Serial0/0
r5#
可以看到R5通过RIP学到了RIP网络的路由,避免了次优路由!!!
R4:
r4#sh ip rou
O E2 192.168.12.0/24 [110/40] via
192.168.34.1, 00:48:17, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2
1.1.1.0 [110/40] via 192.168.45.1, 00:04:06, Serial0/1
[110/40] via 192.168.34.1,
00:04:06, Serial0/0
C
192.168.45.0/24 is directly connected, Serial0/1
O E2 192.168.25.0/24 [110/40] via
192.168.45.1, 00:48:17, Serial0/1
O E2 192.168.23.0/24 [110/40] via
192.168.34.1, 00:48:17, Serial0/0
11.0.0.0/24 is subnetted, 1 subnets
O E2
11.11.11.0 [110/40] via 192.168.45.1, 00:04:06, Serial0/1
[110/40] via 192.168.34.1,
00:04:06, Serial0/0
C
192.168.34.0/24 is directly connected, Serial0/0
r4#
可以看到R4学到的RIP网络的路由实现了负载均衡!!!
这个配置方法不是很好,因为如果我们把R3的连着RIP网络的接口s0/1关掉,这样R3就学习不到RIP网络的路由了,因为R3上面配置了分发列表,禁止R3从S0/0接口学习RIP网络的路由,测试效果如下:
R3:
r3(config)#int s 0/1
r3(config-if)#shutdown
r3#sh ip rou
O
192.168.45.0/24 [110/128] via 192.168.34.2, 00:09:33, Serial0/0
O E2 192.168.25.0/24 [110/40] via
192.168.34.2, 00:09:33, Serial0/0
C
192.168.34.0/24 is directly connected, Serial0/0
r3#
如上,这样R3就丢失了RIP网络的路由!!!下面这个配置方法可以很好的解决这个问题。即可以避免次优路由的产生,又可以适应网络的变化!!!
方法二:
先把R3和R5的分发列表删掉,也要把R3的S0/1接口开起来:
R3:
r3(config)#no acc 1
r3(config)#router os 1
r3(config-router)#no distrib 1 in s0/0
r3(config)#int s 0/1
r3(config-if)#no shutdown
R5:
r5(config)#no acc 1
r5(config)#router os 1
r5(config-router)#no distrib 1 in s0/0
下面配置第二种方法(修改路由AD值):
注意:AD值到本地的路由起作用!!!
R3:
r3(config)#router os 1
r3(config-router)#distance 130 //配置重发布的AD值为130
r3(config)#acc 1 per 192.168.45.0 //关联OSPF内网路由
r3(config)#router os 1
r3(config-router)#distance 110 0.0.0.0 255.255.255.255 1
//配置OSPF内部路由的AD值保持110
R5:
r5(config)#router os 1
r5(config-router)#distance 130
r5(config-router)#acc 1 per 192.168.34.0
r5(config)#router os 1
r5(config-router)#distance 110 0.0.0.0 255.255.255.255 1
r5(config-router)#end
马上就可以看到R5通过RIP学习到RIP网络的路由!!!
r5#sh ip rou
R
192.168.12.0/24 [120/1] via 192.168.25.2, 00:00:06, Serial0/1
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/2] via 192.168.25.2,
00:00:06, Serial0/1
C
192.168.45.0/24 is directly connected, Serial0/0
C
192.168.25.0/24 is directly connected, Serial0/1
R
192.168.23.0/24 [120/1] via 192.168.25.2, 00:00:06, Serial0/1
11.0.0.0/24 is subnetted, 1 subnets
R 11.11.11.0 [120/2] via 192.168.25.2,
00:00:06, Serial0/1
O
192.168.34.0/24 [110/128] via 192.168.45.2, 00:00:05, Serial0/0
r5#
因为R5通过RIP学到的AD值为120,而刚刚在R5上设置的外部路由的AD值为130,路由器根据AD值小的优选进路由表!!!在R4也可以实现负载均衡:
R4:
r4#sh ip rou
O E2 192.168.12.0/24 [110/40] via
192.168.45.1, 00:07:26, Serial0/1
[110/40] via 192.168.34.1,
00:07:26, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2
1.1.1.0 [110/40] via 192.168.45.1, 00:07:26, Serial0/1
[110/40] via 192.168.34.1,
00:07:26, Serial0/0
C
192.168.45.0/24 is directly connected, Serial0/1
O E2
192.168.25.0/24 [110/40] via 192.168.45.1, 00:08:18, Serial0/1
[110/40] via 192.168.34.1,
00:08:18, Serial0/0
O E2 192.168.23.0/24 [110/40] via
192.168.45.1, 00:07:26, Serial0/1
[110/40] via 192.168.34.1,
00:07:26, Serial0/0
11.0.0.0/24 is subnetted, 1 subnets
O
E2 11.11.11.0 [110/40] via
192.168.45.1, 00:07:26, Serial0/1
[110/40] via 192.168.34.1,
00:07:26, Serial0/0
C
192.168.34.0/24 is directly connected, Serial0/0
r4#
而且现在把R3的S0/1关掉,R3也不会丢失RIP网络的路由,测试如下:
R3:
r3(config)#int s0/1
r3(config-if)#shutdown
r3#sh ip rou
O E2 192.168.12.0/24 [130/40] via
192.168.34.2, 00:16:12, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O
E2 1.1.1.0 [130/40] via 192.168.34.2,
00:16:12, Serial0/0
O
192.168.45.0/24 [110/128] via 192.168.34.2, 00:25:51, Serial0/0
O E2 192.168.25.0/24 [130/40] via
192.168.34.2, 00:16:12, Serial0/0
11.0.0.0/24 is subnetted, 1 subnets
O
E2 11.11.11.0 [130/40] via
192.168.34.2, 00:16:12, Serial0/0
C
192.168.34.0/24 is directly connected, Serial0/0
r3#
可以看到R3通过OSPF学习到了RIP网络的路由,虽然这个是次优路由,但总比学习不到好吧!!!
接下来配置任务2.配置R4学习到1.1.1.1/24的路由优先走R3。
这个可以在重发布路由时,将度量值修改一下就可以实现这个功能,具体配置如下:
R3:
r3(config)#acc 2 per 1.1.1.0
r3(config)#route-ma rip_to_ospf 10
r3(config-route-map)#ma add 2
r3(config-route-map)#se me 30
r3(config)#route-ma rip_to_ospf 20
r3(config-route-map)#se me 40
r3(config-route-map)#router os 1
r3(config-router)#re rip rou
r3(config-router)#re rip route-map
rip_to_ospf subnets
R5:
router ospf 1
redistribute rip metric 40 subnets
network 192.168.45.0 0.0.0.255 area 0
distance 130
distance 110 0.0.0.0 255.255.255.255 1
router rip
version 2
redistribute ospf 1 metric 5
network 192.168.25.0
no
auto-summary
测试:
R4:
r4#sh ip rou
O E2 192.168.12.0/24 [110/40] via
192.168.45.1, 00:11:26, Serial0/1
[110/40] via 192.168.34.1,
00:11:26, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0
[110/30] via 192.168.34.1, 00:09:20, Serial0/0
C
192.168.45.0/24 is directly connected, Serial0/1
O E2 192.168.25.0/24 [110/40] via
192.168.45.1, 00:11:26, Serial0/1
[110/40] via 192.168.34.1,
00:11:26, Serial0/0
O E2 192.168.23.0/24 [110/40] via
192.168.45.1, 00:11:42, Serial0/1
[110/40] via 192.168.34.1,
00:11:42, Serial0/0
11.0.0.0/24 is subnetted, 1 subnets
O
E2 11.11.11.0 [110/40] via
192.168.45.1, 00:11:26, Serial0/1
[110/40] via 192.168.34.1,
00:11:26, Serial0/0
C
192.168.34.0/24 is directly connected, Serial0/0
可以看到R4学习到的1.1.1.0/24只有一条路径就是往R3走,而去往11.11.11.0/24有两条路径,可以往R3或R5走!!!以上的配置任务配置成功!!!!!