1:实验拓扑:

2:实验要求:
  要求R1的网络1.1.1.0到R2网络2.2.2.0的十条路径做非等价负载分担。
3:实验环境介绍:
  用4个Ethernet接口,4个S接口,2个F口。
直连接口IP的配置(实验可直接粘贴)
R1
int e0/0
ip add 10.0.0.1 255.255.255.252
no sh
int e0/1
ip add 10.0.1.1 255.255.255.252
no sh
int e0/2
ip add 10.0.2.1 255.255.255.252
no sh
int e0/3
ip add 10.0.3.1 255.255.255.252
no sh

int s1/0
ip add 10.0.4.1 255.255.255.252
no sh
int s1/1
ip add 10.0.5.1 255.255.255.252
no sh
int s1/2
ip add 10.0.6.1 255.255.255.252
no sh
int s1/3
ip add 10.0.7.1 255.255.255.252
no sh
int f2/0
ip add 10.0.8.1 255.255.255.252
no sh
int f3/0
ip add 10.0.9.1 255.255.255.252
no sh
int lo 0
ip add 1.1.1.1 255.255.255.0

===========================
R2
int lo 0
ip add 2.2.2.2 255.255.255.0
int e0/0
ip add 10.0.0.2 255.255.255.252
no sh
int e0/1
ip add 10.0.1.2 255.255.255.252
no sh
int e0/2
ip add 10.0.2.2 255.255.255.252
no sh
int e0/3
ip add 10.0.3.2 255.255.255.252
no sh

int s1/0
ip add 10.0.4.2 255.255.255.252
no sh
int s1/1
ip add 10.0.5.2 255.255.255.252
no sh
int s1/2
ip add 10.0.6.2 255.255.255.252
no sh
int s1/3
ip add 10.0.7.2 255.255.255.252
no sh
int f2/0
ip add 10.0.8.2 255.255.255.252
no sh
int f3/0
ip add 10.0.9.2 255.255.255.252
no sh


测试直连接口连通性:
R1#tclsh
R1(tcl)#foreach holtzhang {
+>(tcl)#10.0.0.2
+>(tcl)#10.0.1.2
+>(tcl)#10.0.2.2
+>(tcl)#10.0.3.2
+>(tcl)#10.0.4.2
+>(tcl)#10.0.5.2
+>(tcl)#10.0.6.2
+>(tcl)#10.0.7.2
+>(tcl)#10.0.8.2
+>(tcl)#10.0.9.2
+>(tcl)#} {
+>(tcl)#ping $holtzhang}
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/39/120 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.1.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 4/32/84 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/31/100 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.3.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/29/100 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.4.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/28/68 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.5.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/36/72 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.6.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/29/72 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.7.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/29/76 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.8.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 12/34/64 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.9.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 8/43/76 ms
配置EIGRP做通网络:
R1(config)#router eigrp 1
R1(config-router)#net
R1(config-router)#network 0.0.0.0 0.0.0.0  

                                               //发布本地的所有路由到eigrp
R1(config-router)#no au
R2(config)#router eigrp 1
R2(config-router)#net 0.0.0.0 0.0.0.0
R2(config-router)#no au
查看eigrp的拓扑表:
R1#sho ip eigrp topology
IP-EIGRP Topology Table for AS(1)/ID(10.0.9.1)

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

P 1.1.1.0/24, 1 successors, FD is 128256
        via Connected, Loopback0
P 2.2.2.0/24, 2 successors, FD is 156160
        via 10.0.8.2 (156160/128256), FastEthernet2/0
        via 10.0.9.2 (156160/128256), FastEthernet3/0
        via 10.0.0.2 (409600/128256), Ethernet0/0
        via 10.0.1.2 (409600/128256), Ethernet0/1
        via 10.0.2.2 (409600/128256), Ethernet0/2
        via 10.0.3.2 (409600/128256), Ethernet0/3
        via 10.0.7.2 (2297856/128256), Serial1/3
        via 10.0.6.2 (2297856/128256), Serial1/2
        via 10.0.5.2 (2297856/128256), Serial1/1
        via 10.0.4.2 (2297856/128256), Serial1/0
查看R1的EIGRP路由表
R1#sho ip route eigrp
     2.0.0.0/24 is subnetted, 1 subnets
D       2.2.2.0 [90/156160] via 10.0.9.2, 00:01:27, FastEthernet3/0
                [90/156160] via 10.0.8.2, 00:01:27, FastEthernet2/0
明明有10条路怎么只走了2条呢?
原因是R1默认是等价负载均衡,找了两个FD最小的f口。要实现非等价负载均衡,需要配置maximum-paths和variance number

4:关键点介绍:
 R1(config)#router eigrp 90
 R1(config-router)# maximum-paths 最大的路径条目,默认为4条
R1(config)#router eigrp 1
R1(config-router)#maximum-paths 10

 Router(config)#router eigrp 90
Router(config-router)#variance number  比值距离 2297856/156160=14.7
R1(config)#router eigrp 1
R1(config-router)#variance ?
  <1-128>  Metric variance multiplier    //默认为1,我们更改为15

R1(config-router)#variance 15            
(最优的FD * variance>=其它路径的FD,就可以做非等开销的负载均衡)或
次优路径的FD/最优路径的FD取整得到variance,即可做非等价负载均衡。
但前提条件是次优路径的AD<最优路径的FD。
R1#sho ip route eigrp
     2.0.0.0/24 is subnetted, 1 subnets
D       2.2.2.0 [90/156160] via 10.0.9.2, 00:00:45, FastEthernet3/0
                [90/156160] via 10.0.8.2, 00:00:45, FastEthernet2/0
                [90/2297856] via 10.0.7.2, 00:00:45, Serial1/3
                [90/2297856] via 10.0.6.2, 00:00:45, Serial1/2
                [90/2297856] via 10.0.5.2, 00:00:45, Serial1/1
                [90/2297856] via 10.0.4.2, 00:00:45, Serial1/0
                [90/409600] via 10.0.3.2, 00:00:45, Ethernet0/3
                [90/409600] via 10.0.2.2, 00:00:45, Ethernet0/2
                [90/409600] via 10.0.1.2, 00:00:45, Ethernet0/1
                [90/409600] via 10.0.0.2, 00:00:45, Ethernet0/0
//发现10条路径已经可以做非等价负载均衡。
• traffic-share balanced             流量负载
• traffic-share min across-interfaces 所有流量走高速链路,即使有次优路径也不走。

顺便总结下:RIP和OSPF的负载均衡:

       R1(config)#router rip

       R1(config-router)# maximum-paths number //默认4,该成10

//rip是以跳数计算路径代价的,所以代价都相同的10条都会走。
 

R1(config)#router ospf  110

       R1(config-router)# maximum-paths number

      

R1 (config-if)# ip ospf cost <value>           //更改开销,改为相同。

//OSPF是以cost计算路径代价的,而且OSPF和RIP都不支持非等价负载均衡,OSPF要让10条路都走,必须手动更改cost。