**实验步骤:

1. 如拓扑为pc机配置ip地址

2. 配置网关与交换机:

Sw21:
     [Sw21]vlan batch 10 20 30 40
     [Sw21]interface gigabitethernet 0/0/1
     [Sw21-GigabitEthernet0/0/1]undo shutdown
     [Sw21-GigabitEthernet0/0/1]port link-type access
     [Sw21-GigabitEthernet0/0/1]port def vlan 10

Sw1的0/0/2 0/0/3 0/0/4端口都如此分别加入vlan 20 vlan 30 vlan 40 交换机之间配置trunk链路: [Sw21-GigabitEthernet0/0/5]port link-type trunk [Sw21-GigabitEthernet0/0/5]port trunk allow-pass vlan all Sw21的0/0/5 0/0/6 sw18 Gw19 Gw20 的0/0/1 0/0/2 端口全部配置trunk链路

3. 配置优先级**:

Gw19: Vlan 10 : [Gw19]in vlan 10 [Gw19-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.250 [Gw19-Vlanif10]vrrp vrid 10 priority 150(配置优先级) Vlan20: [Gw19]in vlan 20 [Gw19-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.250(虚拟ip) [Gw19-Vlanif20]vrrp vrid 20 priority 150 Vlan30: [Gw19]in vlan 30 [Gw19-Vlanif30]vrrp vrid 30 virtual-ip 192.168.30.250 Vlan40: [Gw19]in vlan 40 [Gw19-Vlanif40]vrrp vrid 40 virtual-ip 192.168.40.250 vlan 30与vlan 40 为默认优先级100 Gw20: vlan10: [Gw20]in vlan 10 [Gw20-Vlanif10]vrrp vrid 30 virtual-ip 192.168.10.250 Vlan20: [Gw19]in vlan 20 [Gw20-Vlanif20]vrrp vrid 40 virtual-ip 192.168.20.250 Vlan30: [Gw20]in vlan 30 [Gw20-Vlanif30]vrrp vrid 10 virtual-ip 192.168.30.250 [Gw20-Vlanif30]vrrp vrid 10 priority 150(配置优先级) Vlan40: [Gw20]in vlan 40 [Gw20-Vlanif40]vrrp vrid 20 virtual-ip 192.168.40.250 [Gw20-Vlanif40]vrrp vrid 20 priority 150

4. Pc机网关

   Pc1;192.168.10.250 255.255.255.0
   Pc2:  192.168.20.250 255.255.255.0	
   Pc3:  192.168.30.250 255.255.255.0
   Pc4:  192.168.40..250 255.255.255.0
   在GW19和GW20中配置SVI ip地址,分别是;
         Vlan x 192.168.x.254/24和192.168.x.25324

5. Sw18和路由之间配置192.168.50.0/24网关

6. 验证,测试,保存

线路1或2故障时,vlan10 vlan20 会使用备份电路,整个网络还是通的,平时则会使用GW19,解决单点链路故障,实现了负载均衡 如果线路3或4故障时,可以在端口下设置命令: [Gw19-Vlanif20]Vrrp vrid x track interface gi 0/0/2(监控上一端口状态) [Gw19-Vlanif20]vrrp vrid 10 track int gi 0/0/2 reduced 50(当0/0/2端口down时,其相应的优先级会减少 这就是VRRP的负载均衡以及链路跟踪希望对大家有点帮助,如果有什么不对的地方请大家一定要提出来,一起探讨!!!