【实训背景】
学校为了开展计算机教学和网络办公,建立了一个计算机教室和一个校办公区,这两处的计算机网络通过两台交换机互连组成内部校园网;为了提高网络的可靠性,作为网络管理员的你要用2条链路将交换机互连,现要求在交换机上做适当配置,使网络避免环路。
【实训目的】
掌握生成树协议的配置方法,理解生成树协议的作用和特点
【技术原理】
生成树协议( spanning-tree) ,作用是在交换网络中提供冗余备份链路,并且解决交换 网络中的环路问题。
生成树协议是利用SPA算法(生成树算法),在存在交换环路的网络中生成一个没有环路的树形网络。运用该算法将交换网络冗余的备份链路逻辑上断开,当主要链路出现故障时,能够自动的切换到备份链路,保证数据的正常转发。
生成树协议的特点是收敛时间长。当主要链路出现故障以后,到切换到备份链路需要 50秒的时间。
【实训内容】
1、根据拓扑将主机和交换机进行连接(未形成环路)
2、测试主机之间可以相互ping通
3、配置生成树协议
4、测试(形成环路)
5、测试(断开主要链路)
【实现功能】
使网络在有冗余链路的情况下避免环路的产生,避免广播风暴等。
【实训设备】
s3100(2台),PC(2台)、直连线(4条)
【实训拓扑】
生成树协议的配置_职场
实验时,按照拓扑图进行网络的连接,注意主机和交换机连接的端口。
设备型号
实训名称
IP地址/掩码
网关
端口连接情况
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
【主要命令】
stp, stp mode , spanning-tree Priority, undo stp
【实训步骤】
1、在每台交换机上开启生成树协议.
对 SwitchA 做如下配置:
<H3C>
<H3C> system-view !进入全局配置模式
[H3C]sysname SwitchA
[SwitchA]vlan 10
[SwitchA-vlan10]quit
[SwitchA]interface fastethernet 0/24
[SwitchA- fastethernet 0/24] port acc vlan 10
[SwitchA] interface f 0/1
[SwitchA-fastethernet]port link-type trunk
[SwitchA] interface f 0/2
[SwitchA-fastethernet]port link-type trunk
[SwitchA-fastethernet]quit
[SwitchA]
对 SwitchB 做如下配置:
<H3C>
<H3C> system-view !进入全局配置模式
[H3C]sysname SwitchB
[SwitchB]vlan 10
[SwitchB –vlan10]quit
[SwitchB]interface fastethernet 0/24
[SwitchB-fastethernet] port acc vlan 10
[SwitchB]interface f 0/1
[SwitchB-fastetherne] port link-type trunk
[SwitchB]interface f 0/2
[SwitchB-fastetherne] port link-type trunk
[SwitchB-fastetherne] quit
[SwitchB]
2、设置生成树模式。
stp mode stp!设置生成树模式为 STP (802.1D)
验证测试:验证生成树协模式为 802.1D
<SwitchA>sys
[SwitchA]stp enable !开启生成树协议
[SwitchA] stp mode stp
[SwitchA]quit
<SwitchB>sys
[SwitchB]stp enable !开启生成树协议
[SwitchB] stp mode stp
[SwitchB]quit
验证测试:验证生成树协议已经开启
SwitchA#disp stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.000f-e253-8317 本机桥ID
Bridge Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :32768.000f-e249-d546 / 200 根桥ID及路径开销
CIST RegRoot/IRPC :32768.000f-e253-8317 / 0
CIST RootPortId :128.1 短口ID
BPDU-Protection :disabled
TC-Protection :enabled / Threshold=6
Bridge Config
Digest Snooping :disabled
TC or TCN received :122
Time since last TC :0 days 0h:0m:9s
----[Port1(Ethernet1/0/1)][FORWARDING]---- 发送状态
Port Protocol :enabled
Port Role :CIST Root Port
Port Priority :128
Port Cost(Legacy) :Config=auto / Active=200
Desg. Bridge/Port :32768.000f-e249-d546 / 128.1
Port Edged :Config=disabled / Active=disabled
Point-to-point :Config=auto / Active=true
Transmit Limit :10 packets/hello-time
Protection Type :None
MSTP BPDU format :Config=legacy
Port Config
Digest Snooping :disabled
Num of Vlans Mapped :1
PortTimes :Hello 2s MaxAge 20s FwDly 15s MsgAge 0s RemHop 0
BPDU Sent :3
TCN: 1, Config: 2, RST: 0, MST: 0
BPDU Received :39
TCN: 0, Config: 39, RST: 0, MST: 0

----[Port2(Ethernet1/0/2)][DISCARDING]---- 阻塞状态
Port Protocol :enabled
Port Role :CIST Alternate Port
Port Priority :128
Port Cost(Legacy) :Config=auto / Active=200
Desg. Bridge/Port :32768.000f-e249-d546 / 128.2
Port Edged :Config=disabled / Active=disabled
Point-to-point :Config=auto / Active=true
Transmit Limit :10 packets/hello-time
Protection Type :None
MSTP BPDU format :Config=legacy
Port Config
Digest Snooping :disabled
Num of Vlans Mapped :1
PortTimes :Hello 2s MaxAge 20s FwDly 15s MsgAge 0s RemHop 0
BPDU Sent :2
TCN: 0, Config: 2, RST: 0, MST: 0
BPDU Received :59
TCN: 0, Config: 59, RST: 0, MST: 0
[SwitchA] disp stp int e1/0/1 显示接口STP信息
----[CIST][Port1(Ethernet1/0/1)][FORWARDING]----
Port Protocol :enabled
Port Role :CIST Root Port
Port Priority :128 接口优先级
Port Cost(Legacy) :Config=auto / Active=200
Desg. Bridge/Port :32768.000f-e249-d546 / 128.1
Port Edged :Config=disabled / Active=disabled
Point-to-point :Config=auto / Active=true
Transmit Limit :10 packets/hello-time
Protection Type :None
MSTP BPDU format :Config=legacy
Port Config
Digest Snooping :disabled
Num of Vlans Mapped :1
PortTimes :Hello 2s MaxAge 20s FwDly 15s MsgAge 0s RemHop 0
BPDU Sent :3
TCN: 1, Config: 2, RST: 0, MST: 0
BPDU Received :195
TCN: 0, Config: 195, RST: 0, MST: 0
3、设置交换机的优先级。
[SwitchA] stp priority 0 !设置交换机 SwitchA 在生成树实例0中的优先级为0, 数值最小的交换机为根交换机(也称根桥),交换机 SwitchB 的优先级采用默认优先级(32768),因此 SwitchA 将成为根交换机。
验证测试:验证交换机 SwitchA 的优先级
[SwitchA]display stp
StpVersion : STP
SysStpStatus : Enabled
BaseNumPorts : 24
MaxAge : 20
HelloTime : 2
ForwardDelay : 15
BridgeMaxAge : 20
BridgeHelloTime : 2
BridgeForwardDelay : 15
MaxHops : 20
TxHoldCount : 3
PathCostMethod : Long
BPDUGuard : Disabled
BPDUFilter : Disabled
BridgeAddr : 00d0.f88c.1da0
Priority : 0
TimeSinceTopologyChange : 0d:0h:7m:21s
TopologyChanges : 0
DesignatedRoot : 000000D0F88C1DA0
RootCost : 0
RootPort : 0
[SwitchB] dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.000f-e249-d546 本机桥ID
Bridge Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :32768.000f-e249-d546 / 0 根桥ID及路径开销
CIST RegRoot/IRPC :32768.000f-e249-d546 / 0
CIST RootPortId :0.0
BPDU-Protection :disabled
TC-Protection :enabled / Threshold=6
Bridge Config
Digest Snooping :disabled
TC or TCN received :5
Time since last TC :0 days 0h:3m:11s
----[Port1(Ethernet1/0/1)][FORWARDING]----
Port Protocol :enabled
Port Role :CIST Designated Port
Port Priority :128
Port Cost(Legacy) :Config=auto / Active=200
Desg. Bridge/Port :32768.000f-e249-d546 / 128.1
Port Edged :Config=disabled / Active=disabled
Point-to-point :Config=auto / Active=true
Transmit Limit :10 packets/hello-time
Protection Type :None
MSTP BPDU format :Config=legacy
Port Config
Digest Snooping :disabled
Num of Vlans Mapped :1
PortTimes :Hello 2s MaxAge 20s FwDly 15s MsgAge 0s RemHop 20
BPDU Sent :114
TCN: 0, Config: 114, RST: 0, MST: 0
BPDU Received :1
TCN: 1, Config: 0, RST: 0, MST: 0
----[Port2(Ethernet1/0/2)][FORWARDING]----
Port Protocol :enabled
Port Role :CIST Designated Port
Port Priority :128
Port Cost(Legacy) :Config=auto / Active=200
Desg. Bridge/Port :32768.000f-e249-d546 / 128.2
Port Edged :Config=disabled / Active=disabled
Point-to-point :Config=auto / Active=true
Transmit Limit :10 packets/hello-time
Protection Type :None
MSTP BPDU format :Config=legacy
Port Config
Digest Snooping :disabled
Num of Vlans Mapped :1
PortTimes :Hello 2s MaxAge 20s FwDly 15s MsgAge 0s RemHop 20
BPDU Sent :132
TCN: 0, Config: 132, RST: 0, MST: 0
BPDU Received :0
TCN: 0, Config: 0, RST: 0, MST: 0
4、综合验证测试。
A.验证交换机 SwitchB 的端口 F0/1和 F0/2的状态。
[SwitchB]display stp interface ethernet 1/0/1
-[Port1(Ethernet1/0/1)][FORWARDING]----
Port Protocol :enabled
Port Role :CIST Designated Port
Port Priority :128
Port Cost(Legacy) :Config=auto / Active=200
Desg. Bridge/Port :32768.000f-e249-d546 / 128.1
Port Edged :Config=disabled / Active=disabled
Point-to-point :Config=auto / Active=true
Transmit Limit :10 packets/hello-time
Protection Type :None
MSTP BPDU format :Config=legacy
Port Config
Digest Snooping :disabled
Num of Vlans Mapped :1
PortTimes :Hello 2s MaxAge 20s FwDly 15s MsgAge 0s RemHop 20
BPDU Sent :114
TCN: 0, Config: 114, RST: 0, MST: 0
BPDU Received :1
TCN: 1, Config: 0, RST: 0, MST: 0
[SwitchB]display stp interface ethernet1/ 0/2
-[Port2(Ethernet1/0/2)][FORWARDING]----
Port Protocol :enabled
Port Role :CIST Designated Port
Port Priority :128
Port Cost(Legacy) :Config=auto / Active=200
Desg. Bridge/Port :32768.000f-e249-d546 / 128.2
Port Edged :Config=disabled / Active=disabled
Point-to-point :Config=auto / Active=true
Transmit Limit :10 packets/hello-time
Protection Type :None
MSTP BPDU format :Config=legacy
Port Config
Digest Snooping :disabled
Num of Vlans Mapped :1
PortTimes :Hello 2s MaxAge 20s FwDly 15s MsgAge 0s RemHop 20
BPDU Sent :132
TCN: 0, Config: 132, RST: 0, MST: 0
BPDU Received :0
TCN: 0, Config: 0, RST: 0, MST: 0
B. 验证网络拓扑发生变化时,ping 的丢包情况。
C:\>ping 192.168.10.3 –t !从主机 PC1 ping PC2(用连续 ping),然后拔掉 SwitchA与 SwitchB 的端口 F0/1 之间的连线,观察丢包情况。
C:\>ping 192.168.10.3 -t
Pinging 192.168.10.3 with 32 bytes of data:
Reply from 192.168.10.3: bytes=32 time<1ms TTL=128
Reply from 192.168.10.3: bytes=32 time<1ms TTL=128
Reply from 192.168.10.3: bytes=32 time<1ms TTL=128
Reply from 192.168.10.3: bytes=32 time<1ms TTL=128
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.10.3: bytes=32 time<1ms TTL=128
Reply from 192.168.10.3: bytes=32 time<1ms TTL=128
Reply from 192.168.10.3: bytes=32 time<1ms TTL=128
Reply from 192.168.10.3: bytes=32 time<1ms TTL=128
Reply from 192.168.10.3: bytes=32 time<1ms TTL=128
Reply from 192.168.10.3: bytes=32 time<1ms TTL=128
Reply from 192.168.10.3: bytes=32 time<1ms TTL=128
C. 验证网络拓扑发生变化时,交换机 SwitchB 的端口2的状态变化,并观察生成树的收敛时间。
【注意事项】
h3c交换机缺省是关闭 stp 的,因此,如果网络在物理上存在环路,则必须手工开启 stp。
【参考配置】
1、交换机SwitchA配置
[SwitchA]display curr
System software version : 1.66(3) Build Sep 7 2006 Rel
Building configuration...
Current configuration : 491 bytes
!
version 1.0
!
hostname SwitchA
vlan 1
!
vlan 10
!
enable secret level 1 5 $2>H.Y*T3;C,tZ[V4<D+S(\WQ=G1X)sv
enable secret level 14 5 'Ttj9=G13U7R:>H.4^u_;C,t54U0<D+S
enable secret level 15 5 $2;C,tZ[30<D+S(\49=G1X)sQ:>H.Y*T
!
spanning-tree mode stp
spanning-tree
spanning-tree mst 0 priority 0
interface fastEthernet 0/1
switchport mode trunk
!
interface fastEthernet 0/2
switchport mode trunk
!
interface fastEthernet 0/24
switchport access vlan 10
!
end
2、交换机SwitchB配置
[SwitchB]display curr
System software version : 1.66(3) Build Sep 7 2006 Rel
Building configuration...
Current configuration : 457 bytes
!
version 1.0
!
hostname SwitchB
vlan 1
!
vlan 10
!
enable secret level 1 5 $2,1u_;C3&-8U0<D4'.tj9=GQ+/7R:>H
enable secret level 14 5 'T,1u_;C3U-8U0<D4^.tj9=G54/7R:>H
enable secret level 15 5 $2H.Y*T73C,tZ[V/4D+S(\W&QG1X)sv'
!
spanning-tree mode stp
spanning-tree
interface fastEthernet 0/1
switchport mode trunk
!
interface fastEthernet 0/2
switchport mode trunk
!
interface fastEthernet 0/24
switchport access vlan 10
!
end