实验要求:
本拓扑按典型中小企业网冗余备份及生成树环境进行搭建,通过配置 HSRP 及 STP 来 保证交换网络的冗余备份。
1、SW1 规划 VLAN1、VLAN2、VLAN3,SW1 作为 VTP 的 Server,域名为 sovand
2、SW2 规划为 VTP 的 client,域名与server 统一
3、SW1 和 SW2 之间进行 etherchannel 配置,采用 PAGP 协商,确保三台交换机的链路为 trunk
4、VLAN1 作为三个交换机的管理VLAN,PC1 划入 VLAN2,PC2 划入 VLAN3
5、SW1、SW2 使用 PVST+,SW1 作为奇数 VLAN 的主根,SW2 作为偶数 VLAN 主根
6、SW3 开启 uplinkfast 和 portfast
7、在 SW1 和 SW2 上各起 3 个 VLAN 的 SVI,并规划处 HSRP 的虚拟 IP
8、规划 HSRP 的 active 设备与 STP 主根统一
9、测试 PC 之间的联通性,保证 PC 可以 telnet 任何一个交换机
10、拔掉实际传输链路,测试备份链路传输切换性能
附加实验:
1、把 PVST+改为 MSTP,奇数 VLAN 绑定为实例 1,偶数 VLAN 绑定为实例 2
2、实例 1 的主根为 SW1,实例 2 的主根为 SW2
3、修改 etherchannel 的协商协议,改为 LACP 的 active 模式
实验拓扑:
clip_p_w_picpath002
 

实验步骤:
1、 在配置 VLAN 和 VTP 协议
SW1:
SW1(config)#vlan 2
SW1(config-vlan)#vlan 3
SW1(config-vlan)#exit
SW1(config)#int f0/1
SW1(config-if)#switchport trunk encapsulation dot1q    //在三层接口上封装 802.1Q 协议
SW1(config-if)#switchport mode trunk
SW1(config)#vtp domain sovand    //配置 VTP 域名为 sovand
SW1(config)#vtp mode server    //设置 VTP 服务器模式
SW2:
SW2(config)#int f0/1
SW2(config-if)#switchport trunk encapsulation dot1q
SW2(config-if)#switchport mode trunk
SW2(config)#vtp domain sovand
SW2(config)#vtp mode client
SW3:
SW3(config)#int f0/1
SW3(config-if)#switchport mode trunk
SW3(config)#int f0/2
SW3(config-if)#switchport mode trunk
SW3(config-if)#int f0/3
SW3(config-if)#switchport mode access
SW3(config-if)#switchport access vlan 2
SW3(config-if)#int f0/4
SW3(config-if)#switchport mode access
SW3(config-if)#switchport access vlan 3
SW3(config)#vtp domain sovand
SW3(config)#vtp mode client
2、配置 PAGP 链路聚合协议
SW1:
SW1(config)#int range f0/19 - 20
SW1(config-if-range)channel-protocal pagp    //使用 pagp 协议
SW1(config-if-range)#channel-group 1 mode desirable    //设置为自动协商模式
SW2:
SW1(config)#int range f0/23 - 24
SW1(config-if-range)channel-protocal pagp
SW1(config-if-range)#channel-group 1 mode desirable
查看链路汇聚状态:
SW2#show etherchannel summary
Number of channel-groups in use: 1
Number of aggregators:    1

Group    Port-channel    Protocol    Ports
------+-------------+-----------+-----------------------------------------------
1    Po1(SU)    PAgP    Fa0/23(P)    Fa0/24(P)

SW1#show etherchannel summary
Number of channel-groups in use: 1
Number of aggregators:    1

Group    Port-channel    Protocol    Ports
------+-------------+-----------+-----------------------------------------------
1    Po1(SU)    PAgP    Fa0/19(P)    Fa0/20(P)

3、配置 STP
SW1:
SW1(config)#spanning-tree vlan 2 root secondery        //设定 SW1 为 VLAN2 的辅助根桥
SW1(config)#spanning-tree vlan 3 root primary    //设定 SW1 为 VLAN3 的主根桥
SW2:
SW2(config)#spanning-tree vlan 2 root primary
SW2(config)#spanning-tree vlan 3 root secondery
SW3:
SW3(config)#spanning-tree vlan 2
SW3(config)#spanning-tree vlan 3
查看生成树状态:
SW2#show spanning-tree
VLAN0002
Spanning tree enabled protocol ieee
Root ID     Priority     24578
Address     0012.8077.3200
This bridge is the root     //SW2 为 VLAN2 的根桥
Hello Time     2 sec     Max Age 20 sec     Forward Delay 15 sec

Bridge ID    Priority    24578     (priority 24576 sys-id-ext 2) Address     0012.8077.3200
Hello Time     2 sec     Max Age 20 sec     Forward Delay 15 sec
Aging Time 300
Interface     Role Sts Cost     Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------

Fa0/1    Desg FWD 19    128.1    P2p
Po1    Desg FWD 12    128.65    P2p
VLAN0003
Spanning tree enabled protocol ieee
Root ID    Priority    8195
Address     0022.9062.7380
Cost    12
Port     65 (Port-channel2)
Hello Time     2 sec     Max Age 20 sec     Forward Delay 15 sec

Bridge ID    Priority    28675     (priority 28672 sys-id-ext 3) Address     0012.8077.3200
Hello Time     2 sec     Max Age 20 sec     Forward Delay 15 sec
Aging Time 300

Interface     Role Sts Cost     Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1     Desg FWD 19     128.1     P2p Po1         Root FWD 12       128.65      P2p
开启 uplinkfast 和 portfast
SW3:
SW3(config)#spanning-tree uplinkfast
SW3(config)#int f0/3
SW3(config-if)#spanning-tree portfast
SW3(config)#int f0/4
SW3(config-if)#spanning-tree portfast
查看 uplinkfast 和 portfast:
SW3#show spanning-tree uplinkfast
UplinkFast is enabled
Station update rate set to 150 packets/sec.

UplinkFast statistics
-----------------------
Number of transitions via uplinkFast (all VLANs)    : 15
Number of proxy multicast addresses transmitted (all VLANs) : 88

Name     Interface List
-------------------- ------------------------------------ VLAN0001     Fa0/1(fwd), Fa0/2
VLAN0002     Fa0/1(fwd), Fa0/2
VLAN0003     Fa0/2(fwd), Fa0/1
SW3#show spanning-tree int f0/3 portfast
VLAN0002     enabled
SW3#show spanning-tree int f0/4 portfast
VLAN0003     enabled
4、将 VLAN1 配置为管理 VLAN
SW1:
SW1(config)#ip routing
SW1(config)#int vlan 1
SW1(config-if)#ip add 192.168.1.1 255.255.255.0      //VLAN1 的网关
SW1(config)#line vty 0 4
SW1(config-line)#password cisco
SW1(config-line)#login
SW2:
SW2(config)#ip routing
SW2(config)#int vlan 1
SW2(config-if)#ip add 192.168.1.99 255.255.255.0
SW2(config)#ip default-gateway 192.168.1.1      //网关指向 SW1
SW2(config)#line vty 0 4
SW2(config-line)#password cisco
SW2(config-line)#login
SW3:
SW3(config)#int vlan 1
SW3(config-if)#ip add 192.168.1.100 255.255.255.0
SW3(config)#ip default-gateway 192.168.1.1      //网关指向 SW1
SW3(config)#line vty 0 4
SW3(config-line)#password cisco
SW3(config-line)#login
5、外部启用 EIGRP 协议
SW1:
SW1(config)#int f0/3
SW1(config-if)#no switchport      //开启三层端口功能
SW1(config-if)#ip add 100.1.2.2 255.255.255.0
SW1(config-if)#no shut
SW1(config)#router eigrp 1
SW1(config-router)#net 100.1.2.0
SW1(config-router)#net 192.168.2.0      //将内网通告进去
SW1(config-router)#net 192.168.3.0      //将内网通告进去 SW1(config-router)#no auto-summary
SW2:
SW2(config)#int f0/2
SW2(config-if)#no switchport
SW2(config-if)#ip add 100.1.1.2 255.255.255.0
SW2(config-if)#no shut
SW2(config)#router eigrp 1
SW2(config-router)#net 100.1.1.0
SW2(config-router)#net 192.168.2.0
SW2(config-router)#net 192.168.3.0
SW2(config-router)#no auto-summary
R4:
R4(config)#router eigrp 1
R4(config-router)#net 200.1.1.0
R4(config-router)#net 100.1.2.0
R4(config-router)#net 100.1.1.0
R4(config-router)#no auto-summary
6、使用 HSRP 进行汇聚交换机的备份
SW1:
SW1(config)#int vlan 2
SW1(config-if)#ip add 192.168.2.101 255.255.255.0    //配置 VLAN2 的 IP
SW1(config-if)#standby 1 priority 100    //设置优先级为 100,作为 VLAN2 的备份交换机
SW1(config-if)#standby 1 ip 192.168.2.1    //配置 VLAN2 的虚拟网关
SW1(config-if)#standby 1 preempt    //启用抢占模式
SW1(config-if)#standby 1 timers 1 3    //设置 hello 时间 1 秒,保持时间 3 秒
SW1(config)#int vlan 3
SW1(config-if)#ip add 192.168.3.101 255.255.255.0    //配置 VLAN3 的 IP
SW1(config-if)#standby 1 priority 200    //设置优先级为 200,作为 VLAN3 的活动交换机
SW1(config-if)#standby 1 ip 192.168.3.1    //配置 VLAN3 的虚拟网关
SW1(config-if)#standby 1 preempt    //启用抢占模式
SW1(config-if)#standby 1 timers 1 3
SW2:
SW2(config)#int vlan 2
SW2(config-if)#ip add 192.168.2.100 255.255.255.0    //配置 VLAN2 的 IP
SW2(config-if)#standby 1 priority 200    //设置优先级为 200,作为 VLAN2 的活动交换机
SW2(config-if)#standby 1 ip 192.168.2.1    /配置 VLAN2 的虚拟网关
SW2(config-if)#standby 1 preempt    //启用抢占模式
SW2(config-if)#standby 1 timers 1 3
SW2(config)#int vlan 3
SW2(config-if)#ip add 192.168.3.100 255.255.255.0    //配置 VLAN3 的 IP
SW2(config-if)#standby 1 priority 100    //设置优先级为 100,作为 VLAN3 的备份交换机
SW2(config-if)#standby 1 ip 192.168.3.1    //配置 VLAN3 的虚拟网关
SW2(config-if)#standby 1 preempt    //启用抢占模式
SW2(config-if)#standby 1 timers 1 3
查看 standby:
SW2#show standby vlan 2 br
P indicates configured to preempt.
|

Interface    Grp Prio P State     Active        Standby    Virtual IP
Vl2    1    200    P Active    local        192.168.2.101     192.168.2.1
由上面可见 SW2 为 VLAN2 的 Active 交换机,虚拟网关为 192.168.2.1

SW2#show standby vlan 3 br
P indicates configured to preempt.
|
Interface    Grp Prio P State    Active    Standby    Virtual IP
Vl3     1     100     Standby     192.168.3.101     local     192.168.3.1
由上面可见 SW1 为 VLAN3 的 Active 交换机,虚拟网关为 192.168.3.1
7、将 PVST+改为 MSTP
SW1:
SW1(config)#spanning-tree mode mst    //将生成树改为 MST 模式
SW1(config)#spanning-tree mst configuration    //进入 MST 配置模式
SW1(config-mst)#name sovand    //设置名字为 sovand
SW1(config-mst)#revision 1    //修订号设为 1
SW1(config-mst)#instance 1 vlan 3    //在第一组里包含 VLAN3
SW1(config-mst)#instance 2 vlan 2    //在第二组里包含 VLAN2
SW1(config)#spanning-tree mst 1 root primary    //将 SW1 设为第一组的主根桥 SW1(config)# spanning-tree mst 2 root secondery        //将 SW1 设为第二组的辅助根桥 SW2:
SW2(config)#spanning-tree mode mst SW2(config)#spanning-tree mst configuration SW2(config-mst)#name sovand
SW2(config-mst)#revision 1
SW2(config-mst)#instance 1 vlan 3
SW2(config-mst)#instance 2 vlan 2
SW2(config)#spanning-tree mst 1 root secondery        //将 SW2 设为第一组的辅助根桥 SW2(config)#spanning-tree mst 2 root primary    //将 SW2 设为第二组的主根桥 SW3:
SW3(config)#spanning-tree mode mst SW3(config)#spanning-tree mst configuration SW3(config-mst)#name sovand
SW3(config-mst)#revision 1
SW3(config-mst)#instance 1 vlan 3
SW3(config-mst)#instance 2 vlan 2
查看 MSTP 情况:
SW1#show spanning-tree mst 2
##### MST2    vlans mapped:    2
Bridge    address 0022.9062.7380    priority        28674 (28672 sysid 2)   
Root    address 0012.8077.3200 port    Po1    priority   

cost    24578 (24576 sysid 2)
100000   

rem hops 19

Interface     Role Sts Cost     Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2     Desg FWD 200000     128.4     P2p Pre-STD-Rx Po1         Root FWD 100000         128.56      P2p SW2#show spanning-tree mst 2
##### MST2    vlans mapped:    2
Bridge     address 0012.8077.3200     priority    24578 (24576 sysid 2) Root        this switch for MST2         //SW2 为第二组的主根桥

Interface     Role Sts Cost     Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------

Fa0/1    Desg FWD 200000    128.1     P2p Pre-STD-Rx
Po1    Desg FWD 100000    128.66     P2p

8、将 PAGP 改成 LACP
SW1:
SW1(config)#lacp system-priority 100
SW1(config)#int range f0/19 - 20
SW1(config-if-range)channel-protocal lacp SW1(config-if-range)#channel-group 1 mode active SW1(config-if-range)#lacp port-priority
SW2:
SW1(config)#int range f0/23 - 24
SW1(config-if-range)channel-protocal lacp
SW1(config-if-range)#channel-group 1 mode active
查看 LACP:
SW2#show etherchannel summary
Flags:     D - down     P - in port-channel
I - stand-alone s - suspended
H - Hot-standby (LACP only)
R - Layer3     S - Layer2
U - in use     f - failed to allocate aggregator u - unsuitable for bundling
w - waiting to be aggregated d - default port

Number of channel-groups in use: 2
Number of aggregators:    2

Group     Port-channel     Protocol     Ports
------+-------------+-----------+-----------------------------------------------
1     Po1(SU)     LACP     Fa0/23(P)     Fa0/24(P)

9、在 3560 交换机上配置 SLA 端口跟踪
在 SW1 的出口 F0/3 调用 SLA 进行跟踪,如果 F0/3 的出口链路出现问题,则将 VLAN3 的 active 交换机(SW1)的优先级减少 105(95),比 standby 交换机(SW2)中的优先级(100) 要低。这时 SW2 的抢占功能开始发挥作用,VLAN3 将 SW2 作为新的 active 交换机。
SW1:
SW1(config)# track 1 rtr 1 reachability    //创建一个 track 对 SLA 1 进行跟踪
SW1(config)#ip sla 1    //创建 SLA
SW1(config-sla)#icmp-echo 100.1.2.1 source-ip 100.1.2.2    //使用 ICMP 报文测试两端的联通性
SW1(config-sla)#timeout 2000    //最大 dead 时间为 2000ms
SW1(config-sla)#frequency 3    //频率设为 3 秒
SW1(config-sla)#ip sla schedule 1 life forever start-time now    //起始时间为从现在到永久
SW1(config)#int vlan 3
SW1(config-if)#standby 1 track 1 decrement 105    //在 VLAN3 中调用 truck,如果链路出现问题,则 将 VLAN3 的优先级减少 105
测试备份链路的冗余功能:
首先在设备运行正常的时候,用 PC 对远端的服务器进行一个长 ping,然后再 ping 包 的过程中将 F0/3 shut 掉,查看交换机的冗余情况。
SW1#SHOW standby vlan 3 br
P indicates configured to preempt.
|
Interface    Grp Prio P State    Active    Standby    Virtual IP
Vl3     1     95     P Standby     192.168.3.100     local     192.168.3.1
可见 VLAN3 的 active 交换机优先级已经从 200 减少到了 95
SW2
03:49:02: %HSRP-6-STATECHANGE: Vlan3 Grp 1 state Active -> Speak
04:02:28: %HSRP-6-STATECHANGE: Vlan3 Grp 1 state Standby -> Active    
//VLAN3 的备用交换机 SW2 开始发挥作用
SW1
*Mar     1 03:49:13.340: %HSRP-5-STATECHANGE: Vlan3 Grp 1 state Active -> Speak
*Mar     1 03:49:16.343: %HSRP-5-STATECHANGE: Vlan3 Grp 1 state Speak -> Standby
// 原 active 交换机转变为 standby

PC2#ping 200.1.1.1 repeat 5000
Type escape sequence to abort.
Sending 5000, 100-byte ICMP Echos to 200.1.1.1, timeout is 2 seconds:
……
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!....!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
…….
Success rate is 99 percent (4996/5000), round-trip min/avg/max = 1/2/20 ms
我们可以发现在 ping 包的过程中,如果中间出现了故障,HSRP 的冗余可以在极短的时间内对设备进行切换,使传输过程中丢失包的数量减到最少。可以通过修改 hello 和保持时间来控制,本实验设为1 秒和3 秒。

实验结束。