实验二十一、生成树实验

一、 实验目的

1、了解生成树协议的作用。

2、熟悉生成树协议的配置。

二、 应用环境

交换机之间具有冗余链路本来是一件很好的事情,但是它有可能引起的问题比它能够解

决的问题还要多。如果你真的准备两条以上的路,就必然形成了一个环路,交换机并不知道

如何处理环路,只是周而复始地转发帧,形成一个“死循环”,这个死循环会造成整个网络

处于阻塞状态,导致网络瘫痪。

采用生成树协议可以避免环路。

生成树协议的根本目的是将一个存在物理环路的交换网络变成一个没有环路的逻辑树

形网络。IEEE802.1d 协议通过在交换机上运行一套复杂的算法 STA (spanning-tree

algorithm),使冗余端口置于“阻断状态”,使得接入网络的计算机在与其他计算机通讯时,

只有一条链路生效,而当这个链路出现故障无法使用时,IEEE802.1d 协议会重新计算网络

链路,将处于“阻断状态”的端口重新打开,从而既保障了网络正常运转,又保证了冗余能

力。

三、 实验设备

1、DCS-3926S 交换机 2 台

2、PC机 2 台

3、Console 线1-2 根

4、直通网线 4-8 根

四、 实验拓扑

生成树实验

五、 实验要求

IP 地址设置:

设备 IP Mask

交换机A 10.1.157.100 255.255.255.0

交换机B 10.1.157.101 255.255.255.0

PC1 10.1.157.113 255.255.255.0

PC2 10.1.157.114 255.255.255.0

网线连接:

交换机A e0/0/1 交换机B e0/0/3

交换机A e0/0/2 交换机B e0/0/4

PC1 交换机A e0/0/24

PC2 交换机B e0/0/23

如果生成树成功,则PC1 可以ping 通PC2。

六、 实验步骤

第一步:正确连接网线,恢复出厂设置之后,做初始配置

交换机A:

switch#config

switch(Config)#hostname switchA

switchA(Config)#interface vlan 1

switchA(Config-If-Vlan1)#ip address 10.1.157.100 255.255.255.0

switchA(Config-If-Vlan1)#no shutdown

switchA(Config-If-Vlan1)#exit

switchA(Config)#

交换机B:

switch#config

switch(Config)#hostname switchB

switchB(Config)#interface vlan 1

switchB(Config-If-Vlan1)#ip address 10.1.157.101 255.255.255.0

switchB(Config-If-Vlan1)#no shutdown

switchB(Config-If-Vlan1)#exit

switchB(Config)#

第二步:“PC1 ping PC2 –t ”观察现象

1、ping不通;

2、所有连接网线的端口的绿灯很频繁地闪烁,表明该端口收发数据量很大,已经在交

换机内部形成广播风暴。

第三步:在两台交换机中都使用启用生成树协议

switchA(Config)#spanning-tree mode stp MSTP is starting now, please wait...........

MSTP is enabled successfully.

switchA(Config)#

switchB(Config)#spanning-tree mode stp

MSTP is starting now, please wait...........

MSTP is enabled successfully.

switchB(Config)#

验证配置:

switchA#show spanning-tree

-- MSTP Bridge Config Info --

Standard : IEEE 802.1s

Bridge MAC : 00:03:0f:01:25:28

Bridge Times : Max Age 20, Hello Time 2, Forward Delay 15

Force Version: 3

########################### Instance 0 ###########################

Self Bridge Id : 32768 - 00:03:0f:01:25:28

Root Id : this switch

Ext.RootPathCost : 0

Region Root Id : this switch

Int.RootPathCost : 0

Root Port ID : 0

Current port list in Instance 0:

Ethernet0/0/1 Ethernet0/0/2 (Total 2)

PortName ID ExtRPC IntRPC State Role DsgBridge DsgPort

-------------- ------- --------- --------- --- ---- ------------------ -------

Ethernet0/0/1 128.001 0 0 FWD DSGN 32768.00030f012528 128.001

Ethernet0/0/2 128.002 0 0 FWD DSGN 32768.00030f012528 128.002

switchA#

switchB#show spanning-tree

-- MSTP Bridge Config Info --

Standard : IEEE 802.1s

Bridge MAC : 00:03:0f:01:7d:b0

Bridge Times : Max Age 20, Hello Time 2, Forward Delay 15

Force Version: 3

########################### Instance 0 ###########################

Self Bridge Id : 32768 - 00:03:0f:01:7d:b0

Root Id : 32768.00:03:0f:01:25:28 Ext.RootPathCost : 200000

Region Root Id : this switch

Int.RootPathCost : 0

Root Port ID : 128.4

Current port list in Instance 0:

Ethernet0/0/3 Ethernet0/0/4 Ethernet0/0/23 (Total 3)

PortName ID ExtRPC IntRPC State Role DsgBridge DsgPort

-------------- ------- --------- --------- --- ---- ------------------ -------

Ethernet0/0/3 128.003 0 0 BLK ALTR 32768.00030f012528 128.002

Ethernet0/0/4 128.004 0 0 FWD ROOT 32768.00030f012528 128.001

Ethernet0/0/23 128.023 200000 0 FWD DSGN 32768.00030f017db0 128.023

从show中可以看出,交换机A是根交换机,交换机B的4端口是根端口。