实验时间: 6-3-10
.
实验人:王亮
 
实验名称:配置HSRP,实现网络的负载均衡
实验环境描述:随着公司的发展,公司对网络的要求也越来越高,为此公司决定搭建由两台核心交换机做热备的公司网络,如图,为了充分利用网络资源,公司还要求实现vlan的负载均衡。如图所示,搭建网络实现热备份和vlan的负载均衡。
目标  网络规划如下:交换机之间的接口全部为trunk模式。
sw1sw2上配置hsrp,活跃交换机优先级为150.备份交换机优先级为100.
sw1交换机上配置vlan接口ip地址:
u      Vlan2接口的ip地址:192.168.2.1/24
u      Vlan3接口的ip地址:192.168.3.1/24
u      Vlan4接口的ip地址:192.168.4.1/24
sw2交换机上配置vlan接口ip地址:
u      Vlan2接口的ip地址:192.168.2.2/24
u      Vlan3接口的ip地址:192.168.3.2/24
u      Vlan4接口的ip地址:192.168.4.2/24
PCip地址及网关如下:
u      Pc1ip地址:192.168.2.10/24,网关为192.168.2.254/24
u      Pc2ip地址:192.168.3.10/24,网关为192.168.3.254/24
u      Pc3ip地址:192.168.2.11/24,网关为192.168.2.254/24
u      Pc4ip地址:192.168.4.10/24,网关为192.168.4.254/24
 
需求描述
配置vlan负载均衡时,使用pvsf+并且要求vlan2vlan34实现负载均衡。
交换机网络规划配置:
 
推荐步骤:
1:划分Vlan
2:各交换机都trunk
3:配各VlanIp地址
Hsrp:各个Vlan的虚拟网关,优先级和占先权。
4STp实现负载均衡
三层交换机Sw1配置:
:
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#line con 0
Router(config-line)#no exec-t
Router(config-line)#logg syn
Router(config-line)#exit
Router(config)#no ip do lo
sw1#vlan da
sw1(vlan)#
*Mar  1 00:04:15.947: %SYS-5-CONFIG_I: Configured from console by console
sw1(vlan)#vlan 3
VLAN 3 added:
    Name: VLAN0003
sw1(vlan)#vlan 2
VLAN 2 added:
    Name: VLAN0002
sw1(vlan)#vlan 4
VLAN 4 added:
    Name: VLAN0004
sw1(vlan)#exit
sw1(config)#int range f0/13 -15
sw1(config-if-range)#sw mo tr
sw1(config)#int vlan 2
sw1(config-if)#ip add 192.168.2.1 255.255.255.0
sw1(config-if)#standby 2 ip 192.168.2.254  虚拟网关
sw1(config-if)#standby 2 priority 150 优先级
sw1(config-if)#standby 2 preempt占先权
sw1(config)#int vlan 3
sw1(config-if)#ip add 192.168.3.1 255.255.255.0
sw1(config-if)#standby 3 ip 192.168.3.254
sw1(config-if)#standby 3 priority 150
sw1(config-if)#sta 3 preempt
sw1(config)#int vlan 4
sw1(config-if)#ip add 192.168.4.1 255.255.255.0
sw1(config-if)#no shut
sw1(config-if)#standby 4 ip 192.168.4.254
sw1(config-if)#standby 4 priority 150
sw1(config-if)#standby 4 preempt
sw1#show standby bri
                     P indicates configured to preempt.
                     |
Interface   Grp Prio P State    Active          Standby         Virtual IP    
Vl2         2   150  P Active   local           192.168.2.2     192.168.2.254 
Vl3         3   150  P Active   local           192.168.3.2     192.168.3.254 
Vl4         4   150  P Active   local           192.168.4.2     192.168.4.254 
三层交换机SW2的配置
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#line con 0
Router(config-line)#no exec-t
Router(config-line)#logg syn
Router(config-line)#exit
Router(config)#no ip do lo
w2#vlan da
sw2(vlan)#
*Mar  1 00:04:55.763: %SYS-5-CONFIG_I: Configured from console by console
sw2(vlan)#vlan 2
VLAN 2 added:
    Name: VLAN0002
sw2(vlan)#vlan 3
VLAN 3 added:
    Name: VLAN0003
sw2(vlan)#vlan 4
VLAN 4 added:
    Name: VLAN0004
sw2(vlan)#exit
sw2(config)#int range f0/13 -15
sw2(config-if-range)#sw mo tr
sw2(config)#int vlan 2
sw2(config-if)#ip add 192.168.2.2 255.255.255.0
sw2(config-if)#standby 2 ip 192.168.2.254
sw2(config-if)#standby 2 priority 100
sw2(config-if)#standby 2 preempt
sw2(config)#int vlan 3
sw2(config-if)#ip add 192.168.3.2 255.255.255.0
sw2(config-if)#no shut
sw2(config-if)#stan 3 ip 192.168.3.254
sw2(config-if)#stan 3 priority 100
sw2(config-if)#stan 3 pree 
sw2(config)#int vlan 4
sw2(config-if)#ip add 192.168.4.2 255.255.255.0
sw2(config-if)#stan 4 ip 192.168.4.254
sw2(config-if)#stan 4 pri 100
sw2(config-if)#stan 4 pre
sw2#show stan bri 
                     P indicates configured to preempt.
                     |
Interface   Grp Prio P State    Active          Standby         Virtual IP    
Vl2         2   100  P Standby  192.168.2.1     local           192.168.2.254 
Vl3         3   100  P Standby  192.168.3.1     local           192.168.3.254 
Vl4         4   100  P Standby  192.168.4.1     local           192.168.4.254 
SW3的配置:
sw3#vlan da
sw3(vlan)#vla
*Mar  1 00:04:38.471: %SYS-5-CONFIG_I: Configured from console by console
sw3(vlan)#vlan 2
VLAN 2 added:
    Name: VLAN0002
sw3(vlan)#vlan 3
VLAN 3 added:
    Name: VLAN0003
sw3(vlan)#vlan 4
VLAN 4 added:
    Name: VLAN0004
sw3(vlan)#exit
sw3(config)#int f0/0
sw3(config-if)#sw acc vlan 2
sw3(config-if)#exit
sw3(config)#int f0/1
sw3(config-if)#sw acc vlan 3
sw3(config-if)#exit
sw3(config)#int range f0/14 -15
sw3(config-if-range)#sw mo tr
sw3(config-if-range)#exit
SW4的配置
sw4#vlan da
sw4(vlan)#vlan
*Mar  1 00:03:28.747: %SYS-5-CONFIG_I: Configured from console by console
sw4(vlan)#vlan 2
VLAN 2 added:
    Name: VLAN0002
sw4(vlan)#vlan 3
VLAN 3 added:
    Name: VLAN0003
sw4(vlan)#vlan 4
VLAN 4 added:
    Name: VLAN0004
sw4(vlan)#exit
sw4(config)#int f0/0
sw4(config-if)#sw acc vlan 2
sw4(config-if)#exit
sw4(config)#int f0/1
sw4(config-if)#sw acc vlan 4
sw4(config-if)#exit
sw4(config)#int range f0/14 -15
sw4(config-if-range)#sw mo tr
 
验证HSRP
方案:在两台三层交换机上创建虚拟接口,跟踪虚拟接口,断开虚拟接口,查看HSRP是否有变化。
SW1:
sw1(config)#int loopback 0
sw1(config-if)#int vlan 2
sw1(config-if)#standby 2 track loopback 0 100
sw1(config)#int vlan 3
sw1(config-if)#standby 3 track loopback 0 100
sw1(config)#int vlan 4
sw1(config-if)#standby 4 track loopback 0 100
SW 2:
sw2(config)#int loopback 0
sw2(config)#int vlan 2
sw2(config-if)#standby 2 track loopback 0 100
sw2(config)#int vlan 3
sw2(config-if)#standby 3 track loopback 0 100
sw2(config-if)#exit
sw2(config)#int vlan 4
sw2(config-if)#standby 4 track loopback 0 100
SW 1:断开跟踪端口
sw1(config)#int loopback 0
sw1(config-if)#shutdown
sw1#show standby bri
                     P indicates configured to preempt.
                     |
Interface   Grp Prio P State    Active          Standby         Virtual IP    
Vl2         2   50   P Standby  192.168.2.2     local           192.168.2.254 
Vl3         3   50   P Standby  192.168.3.2     local           192.168.3.254 
Vl4         4   50   P Standby  192.168.4.2     local           192.168.4.254 
SW 2:
sw2#show standby bri
                     P indicates configured to preempt.
                     |
Interface   Grp Prio P State    Active          Standby         Virtual IP    
Vl2         2   100  P Active   local           192.168.2.1     192.168.2.254 
Vl3         3   100  P Active   local           192.168.3.1     192.168.3.254 
Vl4         4   100  P Active   local           192.168.4.1     192.168.4.254 
 
Vlan  负载均衡验证:
SW1
sw1(config)#spanning-tree vlan 2 priority 4096
sw1#show spanning-tree vlan 2 bri
 
VLAN2
  Spanning tree enabled protocol ieee
  Root ID    Priority    4096
             Address     cc00.0afc.0001
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
 
  Bridge ID  Priority    4096
             Address     cc00.0afc.0001
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300
 
Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/13     128.14   128    19 FWD     0  4096 cc00.0afc.0001 128.14
FastEthernet0/14     128.15   128    19 FWD     0  4096 cc00.0afc.0001 128.15
FastEthernet0/15     128.16   128    19 FWD     0  4096 cc00.0afc.0001 128.16
SW2
sw2(config)#spanning-tree vlan 3 priority 4096
sw2(config)#spanning-tree vlan 4 priority 4096
VLAN3
  Spanning tree enabled protocol ieee
  Root ID    Priority    4096
             Address     cc00.0d00.0002
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
 
  Bridge ID  Priority    4096
             Address     cc00.0d00.0002
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300
 
Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/13     128.14   128    19 FWD     0  4096 cc00.0d00.0002 128.14
FastEthernet0/14     128.15   128    19 FWD     0  4096 cc00.0d00.0002 128.15
FastEthernet0/15     128.16   128    19 FWD     0  4096 cc00.0d00.0002 128.16
 
VLAN4
  Spanning tree enabled protocol ieee
  Root ID    Priority    4096
             Address     cc00.0d00.0003
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
 
  Bridge ID  Priority    4096
             Address     cc00.0d00.0003
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300
 
Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/13     128.14   128    19 FWD     0  4096 cc00.0d00.0003 128.14
FastEthernet0/14     128.15   128    19 FWD     0  4096 cc00.0d00.0003 128.15
FastEthernet0/15     128.16   128    19 FWD     0  4096 cc00.0d00.0003 128.16