Lab EIGRP不等价负载均衡

实验目的:在eigrp中如何做到不等值路由的负载均衡

EIGRP Load Balancing 

  每个路由协议都支持等值路径的负载均衡.除此之外,IGRP和EIGRP也支持不等值路径的负载均衡,使用variance命令. Variance命令向路由器通告一个n值,n值使用variance命令指定.n值为1-128之间,默认为1。 
router E有三个路径到网络X 
• E-B-A with a metric of 30 
• E-C-A with a metric of 20 
• E-D-A with a metric of 45 

  Router E选择第二个路径,E-C-A的metric为20,20为三个路径的最小值,如果希望EIGRP选择优先E-B-A路径,配置variance值为乘数2 
router eigrp 1 
network x.x.x.x 
variance 2 

  这样增加了metric到40(2*20=40)。这样EIGRP包括了所有metric小于40的路由,在上面的配置中,路由器使用了两个路径到达网络X,E-C-A和E-B-A,因为两个路径的metric值都在40以下。因为E-D-A的metric为45,大于40,所以eigrp不选择此路径到达网络X。而且,路由器D报告到达网络X的metric为25,这个值比可行的metric值20要大。这就意味着即使variance设置为3,E-D-A路径也不会被选择为负载均衡的路径,因为router D不是一个可行的后继者。 

Traffic Sharing 

  Eigrp不仅支持不等值路径的负载均衡,而且也支持智能负载均衡,例如traffic sharing。有多个路由到达同一目的网络有不同cost的情况下,想要控制在不同路由上的traffic,可以使用traffic sharing命令。使用balanced关键字,路由器按照不同路由的metrics比率成比例的分配流量。这是默认设置 

router eigrp 1 
network x.x.x.x 
variance 2 
traffic-share balanced 

下面是traffic share计算案例 
• For path E-C-A: 30/20 = 3/2 = 1 
• For path E-B-A: 30/30 = 1 

  如果不能整除,我们按照其整数计算(注意:不是四舍五入)。在这个案例中eigrp发送包通过E-C-A和E-B-A的比率为1:1,这样做到了负载均衡的目的。 

  现在我们假设在E-B间的metric为25,B-A间的metric为15。这样E-B-A的metric为40,因为40不小于2×20(20是可行的路径metric,2是variance值),这样在E-C-A和E-B-A之间不可以实现负载均衡。如果希望实现负载均衡,我们需要将variance值设置为3。这样两条链路上的traffic share比率为 
• For path E-C-A: 40/20 = 2 
• For path E-B-A: 40/40 = 1 

  这样eigrp在E-C-A和E-B-A的流量比率为2:1。通过这样的方法,eigrp不仅支持了不等值的路由负载均衡,而且也支持了智能负载均衡 

  在关键字min使用时,traffic仅仅通过最小cost路径发送,即使在路由表中有多个路由路径 
router eigrp 1 
network x.x.x.x 
variance 3 
traffic-share min across-interfaces 

这样配置的结果是,eigrp仅仅通过E-C-A的路径发送 
此文章同样适用于igrp

Step 1 :基本配置
R1
int f0/0
no sh
int f0/0.13
en do 13
ip add 13.1.1.1 255.255.255.0
int s2/2
no sh
ip add 12.1.1.1 255.255.255.0

router eigrp 100
no au
net 12.0.0.0
net 13.0.0.0

R2
int f0/0
no sh
int f0/0.24
en do 24
ip add 24.1.1.2 255.255.255.0
int s2/2
no sh
ip add 12.1.1.2 255.255.255.0

router eigrp 100
no au
net 12.0.0.0
net 24.0.0.0

R3
int f0/0
no sh
int f0/0.13
en do 13
ip add 13.1.1.3 255.255.255.0
int f0/0.34
en do 34
ip add 34.1.1.3 255.255.255.0

router eigrp 100
no au
net 34.0.0.0
net 13.0.0.0

R4
int f0/0
no sh
int f0/0.24
en do 24
ip add 24.1.1.4 255.255.255.0
int f0/0.34
en do 34
ip add 34.1.1.4 255.255.255.0

router eigrp 100
no au
net 34.0.0.0
net 24.0.0.0
net 4.0.0.0

int lo 0
ip add 4.4.4.4 255.255.255.255

Step 2 :查看R1的路由表,此时R1到达4.4.4.4的路由只有一条。
R1#sh ip route 
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

     34.0.0.0/24 is subnetted, 1 subnets
D       34.1.1.0 [90/30720] via 13.1.1.3, 00:00:50, FastEthernet0/0.13
     4.0.0.0/32 is subnetted, 1 subnets
D       4.4.4.4 [90/158720] via 13.1.1.3, 00:00:50, FastEthernet0/0.13
     24.0.0.0/24 is subnetted, 1 subnets
D       24.1.1.0 [90/33280] via 13.1.1.3, 00:00:50, FastEthernet0/0.13
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial2/2
     13.0.0.0/24 is subnetted, 1 subnets
C       13.1.1.0 is directly connected, FastEthernet0/0.13

Step 3 :再查看拓扑表,到达4.4.4.4,有两条路径,但是开销不一样。
R1#sh ip eigrp topology 
IP-EIGRP Topology Table for AS(100)/ID(13.1.1.1)

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status 

P 4.4.4.4/32, 1 successors, FD is 158720
        via 13.1.1.3 (158720/156160), FastEthernet0/0.13
        via 12.1.1.2 (2300416/156160), Serial2/2
P 12.1.1.0/24, 1 successors, FD is 2169856
        via Connected, Serial2/2
P 13.1.1.0/24, 1 successors, FD is 28160
        via Connected, FastEthernet0/0.13
P 24.1.1.0/24, 1 successors, FD is 33280
        via 13.1.1.3 (33280/30720), FastEthernet0/0.13
        via 12.1.1.2 (2172416/28160), Serial2/2
P 34.1.1.0/24, 1 successors, FD is 30720
        via 13.1.1.3 (30720/28160), FastEthernet0/0.13

Step 4 :根据以上的理论知识,将后继路由的FD乘以15。
158720*15=2380800 >另一条路径 2300416
所以在R1上配置
R1(config)#router eigrp 100
R1(config-router)#variance 15

Step 5 :查看路由表。
R1#sh ip route 
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

     34.0.0.0/24 is subnetted, 1 subnets
D       34.1.1.0 [90/30720] via 13.1.1.3, 00:00:02, FastEthernet0/0.13
     4.0.0.0/32 is subnetted, 1 subnets
D       4.4.4.4 [90/158720] via 13.1.1.3, 00:00:02, FastEthernet0/0.13
                [90/2300416] via 12.1.1.2, 00:00:02, Serial2/2
     24.0.0.0/24 is subnetted, 1 subnets
D       24.1.1.0 [90/33280] via 13.1.1.3, 00:00:02, FastEthernet0/0.13
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial2/2
     13.0.0.0/24 is subnetted, 1 subnets
C       13.1.1.0 is directly connected, FastEthernet0/0.13

实验完成