拓扑图:
配置任务:
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
走!!!以上的配置任务配置成功!!!!!