1、等价负载均衡

当到达目的地有多条路径时,而有多条路径的metric值一样,这时就可以做等价负载均衡,让数据包均衡转发,不过要看该路由器的转发方式,如果是快速转发方式,这种方式无用(本地产生的数据包除外)。

2、非等价负载均衡

只有eigrp可以做非等价负载均衡,意思是,到达同一目的地有多条路径,而它们的度量值不一样时,可以做非等价负载均衡,可以通过设置variance值来进行不等价负载均衡,即两数相除取整加1,满足此条件的线路就可以按非等价负载均衡的方式发送数据包,非等价最大支持16条(猜的,不一定),也要看数据包的转发方式,如果是快速转发方式,效果但不到,但是对于本地产生的数据包可以实现非等价,因为此时,本地产生的数据包还是按进程转发方式转发数据包的,对其他路由器的数据包,要关闭快速转发,可以启用cef,且cef对本地的数据包也是产生效果的,记住,不能更改默认的均衡方式,即默认的traffic-share balanced命令不能被修改!

1、EIGRP默认支持四条链路的不等代价的负载均衡(所有路由基本上都支持); 2、使用下面命令可支持六条: router EIGRP 10 maximum-paths 6——设置成6条 variance——后跟差异度量值,实现负载均衡。差异值为1时,只有相同度量才会安置到本地路由表中,为2时,任一由EIGRP发现的了解的路由,只有其度量少于继任度量的两倍,将会被安置到本地的路由表中。

在做实验之前我想先解释一下实现EIGRP负载的一些知识(图)! 一:思考 如果R1想去去往R5的话,那么它面临着有3条路可以走,但是我们可以请注意到,3条路的度量值是不一样的,所以度量值不一样即不能实现负载均衡,于是R1就会选择R3做为它的下一跳,把它放入路由表当中,那我们怎样实现非等价负载呢(即带宽不一致的情况)? 二:术语 AD(Advertise Distance):宣告距离 (邻居到某网络的距离) FD (Feasible Distance):可行距离 (自己到某网络的距离) 如图所示: 如果R1从R3到R5,那么它的AD=10,FD=20. 注:这个一定得搞清,不然接下来都不知道我讲什么. 三:条件

  1. 如果我在R1配置R1(config-router)#variance 2的话,那么R2会做为R1的另一条去住R5的路径,因为2*(FD)>(20+10=30),即从R2到R5的FD小于R3到R5的FD,所以才能实现负载. 2.如果我variance设置为3的话,那么按我刚刚所说的从R4到R5的FD也小于2*(FD),那它会被加入的负载路径里面去吗?答案肯定不会,因为还有一个条件就是AD必需小于FD,从R4到R5的AD为25,而从R3到R5的FD为20,所以不满足,不能实现负载. 实验:拓扑如下 注:写了R1的配置,其它一样。

步骤一:首先先把所以接口信息以及EIGRP全部启用,并且查看信息. R1: Router> Router>en Router#conf t Router(config)#hostname R1 R1(config)#interface f0/0 R1(config-if)#ip address 192.168.12.1 255.255.255.0 R1(config-if)#no sh R1(config-if)#ip address 192.168.13.1 255.255.255.0 R1(config-if)#no sh R1(config-if)#exit R1(config)#router eigrp 1 R1(config-router)#no auto-summary R1(config-router)#network 192.168.12.0 0.0.0.255 R1(config-router)#network 192.168.13.0 0.0.0.255 R1(config-if)#end R1# R1上查看路由表: R1#show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP i - IS-IS, 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 4.0.0.0/24 is subnetted, 1 subnets D 4.4.4.0 [90/158720] via 192.168.13.2, 00:00:06, FastEthernet0/1 [90/158720] via 192.168.12.2, 00:00:06, FastEthernet0/0 C 192.168.12.0/24 is directly connected, FastEthernet0/0 C 192.168.13.0/24 is directly connected, FastEthernet0/1 D 192.168.24.0/24 [90/30720] via 192.168.12.2, 00:04:00, FastEthernet0/0 D 192.168.34.0/24 [90/30720] via 192.168.13.2, 00:03:50, FastEthernet0/1 R1# 注:很清楚的看到,去往4.4.4.4有两条路可以走,因为其度量值一样,EIGRP自动实现负载均衡, 步骤二:R1设置F0/1接口带宽为512KB,其两边度量值不一样,使得所以数据只向F0/0转发,产查看路由表与拓扑表. R1(config)#interface f0/1 R1(config-if)#bandwidth 512 R1(config-if)#end R1# 查看路由表: R1#show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP i - IS-IS, 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 4.0.0.0/24 is subnetted, 1 subnets D 4.4.4.0 [90/158720] via 192.168.12.2, 00:08:43, FastEthernet0/0//这里因为改变F0/1了带宽,所以去住4.4.4.4全部往F0/0转发.只有一条. C 192.168.12.0/24 is directly connected, FastEthernet0/0 C 192.168.13.0/24 is directly connected, FastEthernet0/1 D 192.168.24.0/24 [90/30720] via 192.168.12.2, 00:12:37, FastEthernet0/0 D 192.168.34.0/24 [90/33280] via 192.168.12.2, 00:01:04, FastEthernet0/0 R1#

R1(config)#do sh ip eigrp topo IP-EIGRP Topology Table for AS 1 Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply, r - Reply status P 192.168.12.0/24, 1 successors, FD is 28160 via Connected, FastEthernet0/0 P 192.168.13.0/24, 1 successors, FD is 5002496 via Connected, FastEthernet0/1 P 192.168.24.0/24, 1 successors, FD is 30720 via 192.168.12.2 (30720/28160), FastEthernet0/0 P 192.168.34.0/24, 1 successors, FD is 33280 via 192.168.12.2 (33280/30720), FastEthernet0/0 via 192.168.13.2 (5005056/28160), FastEthernet0/1 P 4.4.4.4/32, 1 successors, FD is 158720 via 192.168.12.2 (158720/156160), FastEthernet0/0 via 192.168.13.2 (5133056/156160), FastEthernet0/1//通过查看拓扑表可以知道通过R2到R4的可行距离FD=158720,而通过R3到R4的可行距离FD=5133056。 步骤三:实现非等价负载均衡 R1(config)#router eigrp 1 R1(config-router)#variance 33 // 33=[5133056/158720]+1,满足条件. 查看路由表: R1#show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP i - IS-IS, 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 4.0.0.0/24 is subnetted, 1 subnets D 4.4.4.0 [90/5133056] via 192.168.13.2, 00:00:02, FastEthernet0/1 [90/158720] via 192.168.12.2, 00:00:01, FastEthernet0/0 C 192.168.12.0/24 is directly connected, FastEthernet0/0 C 192.168.13.0/24 is directly connected, FastEthernet0/1 D 192.168.24.0/24 [90/30720] via 192.168.12.2, 00:00:01, FastEthernet0/0 D 192.168.34.0/24 [90/30720] via 192.168.13.2, 00:00:02, FastEthernet0/1 R1# // 去往4.4.4.4的路由,又变成了两条.