27
科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11 267 / 621 Lab 07 - STP 思科实验 - STP 华为实验 - STP 思科 vs 华为:STP

科迪网络 TechNow CCNA (HCIA) 路由交换配置 …

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

267 / 621

Lab 07 - STP

思科实验 - STP

华为实验 - STP

思科 vs 华为:STP

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

268 / 621

C7 思科实验 – STP

7.1 实验拓扑

7.2 配置步骤

1 交换机 S1~S4 的初始化配置;

2 观察 STP 的选举;

第一步:选举根网桥;

第二步:非根桥选举根端口;

第三步:每个网段选举指定口;

第四步:根端口和指定口为转发状态;其余端口(AP 口)为阻断状态。

3 将 S2 配置为 VLAN 1 的根桥(root bridge);

观察根端口的选举;

观察指定口的选举;

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

269 / 621

7.3 配置参考

1 交换机 S1~S4 的初始化配置

首先在交换机 S1~S4 上,将不用的端口关闭,确保相关的端口开启。

Switch>en

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#hostname SW01

SW01(config)#no ip domain-lookup

SW01(config)#line console 0

SW01(config-line)#logging synchronous

SW01(config-line)#exec-timeout 0 0

SW01(config-line)#exit

SW01(config)#

SW01(config)#$int range e0/0-3,e1/0-3,e2/0-3,e3/0-3,e4/0-3 !* 关闭所有端口

SW01(config-if-range)#shutdown

SW01(config-if-range)#int range e2/0,e3/0-1,e4/0 !* 开启相关的端口

SW01(config-if-range)#no shutdown

SW01(config-if-range)#end

SW01#

Switch>en

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#hostname SW02

SW02(config)#no ip domain-lookup

SW02(config)#line console 0

SW02(config-line)#logging synchronous

SW02(config-line)#exec-timeout 0 0

SW02(config-line)#exit

SW02(config)#

SW02(config)#$int range e0/0-3,e1/0-3,e2/0-3,e3/0-3,e4/0-3 !* 关闭所有端口

SW02(config-if-range)#shutdown

SW02(config-if-range)#int range e2/0,e3/0 !* 开启相关的端口

SW02(config-if-range)#no shutdown

SW02(config-if-range)#end

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

270 / 621

SW02#

Switch>en

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#hostname SW03

SW03(config)#no ip domain-lookup

SW03(config)#line console 0

SW03(config-line)#logging synchronous

SW03(config-line)#exec-timeout 0 0

SW03(config-line)#exit

SW03(config)#

SW03(config)#$int range e0/0-3,e1/0-3,e2/0-3,e3/0-3,e4/0-3 !* 关闭所有端口

SW03(config-if-range)#shutdown

SW03(config-if-range)#int range e2/0,e3/0-1 !* 开启相关的端口

SW03(config-if-range)#no shutdown

SW03(config-if-range)#end

SW03#

Switch>en

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#hostname SW04

SW04(config)#no ip domain-lookup

SW04(config)#line console 0

SW04(config-line)#logging synchronous

SW04(config-line)#exec-timeout 0 0

SW04(config-line)#exit

SW04(config)#

SW04(config)#$int range e0/0-3,e1/0-3,e2/0-3,e3/0-3,e4/0-3 !* 关闭所有端口

SW04(config-if-range)#shutdown

SW04(config-if-range)#int range e2/0,e3/0,e4/0 !* 开启相关的端口

SW04(config-if-range)#no shutdown

SW04(config-if-range)#end

SW04#

非常简单!

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

271 / 621

2 观察 STP 的选举

注意:STP 协议在交换机上是默认启用的!

注意:思科交换机上,是 PVST(Per-Vlan Spanning Tree)。

在查看这些交换机的 stp 属性之前,我们必须要回顾一下 STP 的选举过程和选举原则。

STP 的选举过程

步骤 选举 选举原则

1 每个网络选举唯一的根网桥 先比优先级,越小越优先;

如果优先级相同,再比网桥的 MAC 地址,越小越优先。

2 每个非根桥选举唯一的根端口 先比前往根桥的 Path Cost,越小越优先;

如果 Path Cost 相同,再比发送者的网桥 ID,越小越优先;

如果发送者的网桥 ID 相同,再比发送者的端口 ID,越小越优先。

3 每个网段选举唯一的指定端口 根桥上的口都是指定口;

先比前往根桥的 Path Cost,越小越优先;

如果 Path Cost 相同,再比发送者的网桥 ID,越小越优先。

4 确定端口状态 选举过程结束之后:

根端口和指定端口进入转发状态;

其余端口保持阻塞状态。

选举过程结束之后,根端口和指定端口进入转发状态;其余端口进入阻塞状态。

了解以上信息之后,查看这些交换机的 STP 信息。

2-1 第一步:选举根网桥

我们来看这四个交换机,哪个应该成为根网桥?

注意:你需要拿出笔和纸,在纸上画出网络拓扑,并且记载后面命令的输出结果!因为,每个交换机的

MAC 地址是不一样的!

呵呵,不许偷懒!

在 S1~S4 上,利用“show spanning-tree ”或者“show spannint-tree bridge”命令,查看自己的 BID。

下面,在交换机 S1 上,用这两个命令,展示一下。

SW01#sh spanning-tree

VLAN0001

Spanning tree enabled protocol ieee !* ieee 就是 802.1D

Root ID Priority 32769 !* 这一段,说的是根桥的信息

Address aabb.cc00.3300

This bridge is the root

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

272 / 621

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32769 (priority 32768 sys-id-ext 1) !* 这一段,说的是自己的信息

Address aabb.cc00.3300

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Aging Time 300 sec

Interface Role Sts Cost Prio.Nbr Type

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

Et2/0 Desg FWD 100 128.9 Shr

Et3/0 Desg FWD 100 128.13 Shr

Et3/1 Desg FWD 100 128.14 Shr

Et4/0 Desg FWD 100 128.17 Shr

SW01#

SW01#sh spanning-tree bridge

Hello Max Fwd

Vlan Bridge ID Time Age Dly Protocol

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

VLAN0001 32769 (32768, 1) aabb.cc00.3300 2 20 15 ieee

SW01#

下面,在交换机 S2~S4 上,利用“show spanning-tree bridge”命令,查看 BID。

SW02#sh spanning-tree bridge

Hello Max Fwd

Vlan Bridge ID Time Age Dly Protocol

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

VLAN0001 32769 (32768, 1) aabb.cc00.3400 2 20 15 ieee

SW02#

SW03#sh spanning-tree bridge

Hello Max Fwd

Vlan Bridge ID Time Age Dly Protocol

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

273 / 621

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

VLAN0001 32769 (32768, 1) aabb.cc00.3500 2 20 15 ieee

SW03#

SW04#sh spanning-tree bridge

Hello Max Fwd

Vlan Bridge ID Time Age Dly Protocol

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

VLAN0001 32769 (32768, 1) aabb.cc00.3600 2 20 15 ieee

SW04#

我们看到:

S1 的 BID:32769 (32768, 1) aabb.cc00.3300;

S2 的 BID:32769 (32768, 1) aabb.cc00.3400;

S3 的 BID:32769 (32768, 1) aabb.cc00.3500;

S4 的 BID:32769 (32768, 1) aabb.cc00.3600。

注意:选择网桥 ID 最小的为根网桥,先比较优先级最小,再比较 MAC 地址最小。

所以,S1 成为根网桥!

你可以在这些交换机上,利用“show spanning-tree root”命令,查看根桥的信息。这里就不再赘述!

2-2 第二步:非根桥选举根端口

既然交换机 S1 成为根桥,那么交换机 S2,S3 和 S4 就是非根桥。

注意:每个非根桥上选举唯一的根端口。先比前往根桥的 Path Cost,越小越优先!

思科交换机的生成树的 Cost 值默认为【原始】;华为交换机的生成树的 Cost 值默认为【ieee 802.1t】。

带宽 原始(旧) 802.1t(新)

10M 100 2,000,000

100M 19 200,000

1,000M 4 20,000

10,000M 2 2,000

补充一下,有关 Cisco 的接口 cost 值。

Default Observed on Cisco Switches

常见 Speed Port Cost Comment

Y 10 Mbps 100 Ethernet

20 Mbps 56 EtherChannel

30 Mbps 47 EtherChannel

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

274 / 621

40 Mbps 41 EtherChannel

50 Mbps 35 EtherChannel

54 Mbps 33 802.11 wireless

60 Mbps 30 EtherChannel

70 Mbps 26 EtherChannel

80 Mbps 23 EtherChannel

Y 100 Mbps 19 Fast Ethernet

200 Mbps 12 Fast EtherChannel

300 Mbps 9 Fast EtherChannel

400 Mbps 8 Fast EtherChannel

500 Mbps 7 Fast EtherChannel

600 Mbps 6 Fast EtherChannel

700 Mbps 5 Fast EtherChannel

800 Mbps 5 Fast EtherChannel

Y 1 Gbps 4 Gigabit Ethernet

2 Gbps 3 Gigabit EtherChannel

Y 10 Gbps 2 10G Ethernet

20 Gbps 1 20G EtherChannel

40 Gbps 1 40G EtherChannel

继续……

先看交换机 S2

SW02#

SW02#sh spanning-tree

VLAN0001

Spanning tree enabled protocol ieee

Root ID Priority 32769

Address aabb.cc00.3300

Cost 100

Port 9 (Ethernet2/0)

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)

Address aabb.cc00.3400

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

275 / 621

Aging Time 300 sec

Interface Role Sts Cost Prio.Nbr Type

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

Et2/0 Root FWD 100 128.9 Shr !* 这是根端口

Et3/0 Desg FWD 100 128.13 Shr

SW02#

SW03#sh spanning-tree

VLAN0001

Spanning tree enabled protocol ieee

Root ID Priority 32769

Address aabb.cc00.3300

Cost 100

Port 13 (Ethernet3/0)

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)

Address aabb.cc00.3500

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Aging Time 300 sec

Interface Role Sts Cost Prio.Nbr Type

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

Et2/0 Desg FWD 100 128.9 Shr

Et3/0 Root FWD 100 128.13 Shr !* 这是根端口

Et3/1 Altn BLK 100 128.14 Shr

SW03#

SW04#sh spanning-tree

VLAN0001

Spanning tree enabled protocol ieee

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

276 / 621

Root ID Priority 32769

Address aabb.cc00.3300

Cost 100

Port 17 (Ethernet4/0)

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)

Address aabb.cc00.3600

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Aging Time 300 sec

Interface Role Sts Cost Prio.Nbr Type

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

Et2/0 Altn BLK 100 128.9 Shr

Et3/0 Altn BLK 100 128.13 Shr

Et4/0 Root FWD 100 128.17 Shr !* 这是根端口

SW04#

注意:每个非根桥上选举唯一的根端口。先比前往根桥的 Path Cost,越小越优先!

2-3 第三步:每个网段选举指定口

接下来,每个网段选举一个指定口。

注意,指定口的选举规则:

根桥上的口都是指定口;

先比前往根桥的 Path Cost,越小越优先;

如果 Path Cost 相同,再比发送者的网桥 ID,越小越优先。

观察拓扑,即可。

2-4 第四步:根端口和指定口为转发状态;其余端口(AP 口)为阻断状态。

观察拓扑即可知道,交换机 S3 的 E3/1,交换机 S4 的 E2/0 和 E3/0 成为阻塞端口(AP 口)。

SW03#sh spanning-tree

VLAN0001

Spanning tree enabled protocol ieee

Root ID Priority 32769

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

277 / 621

Address aabb.cc00.3300

Cost 100

Port 13 (Ethernet3/0)

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)

Address aabb.cc00.3500

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Aging Time 300 sec

Interface Role Sts Cost Prio.Nbr Type

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

Et2/0 Desg FWD 100 128.9 Shr

Et3/0 Root FWD 100 128.13 Shr

Et3/1 Altn BLK 100 128.14 Shr !* 阻塞端口

SW03#

SW04#sh spanning-tree

VLAN0001

Spanning tree enabled protocol ieee

Root ID Priority 32769

Address aabb.cc00.3300

Cost 100

Port 17 (Ethernet4/0)

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)

Address aabb.cc00.3600

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Aging Time 300 sec

Interface Role Sts Cost Prio.Nbr Type

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

Et2/0 Altn BLK 100 128.9 Shr !* 阻塞端口

Et3/0 Altn BLK 100 128.13 Shr !* 阻塞端口

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

278 / 621

Et4/0 Root FWD 100 128.17 Shr

SW04#

告一段落!

3 将 S2 配置为 VLAN 1 的根桥(root bridge)

接下来,我们改变交换机 S2 的优先级(将默认优先级 32768 改为 4096),让交换机 S2 成为根桥。

SW02#conf t

Enter configuration commands, one per line. End with CNTL/Z.

SW02(config)#spanning-tree vlan 1 priority 4096

SW02(config)#end

SW02#

如下图所示

注意:网桥优先级的取值范围必须是 4096 的整数倍:

% Allowed values are:

0 4096 8192 12288 16384 20480 24576 28672

32768 36864 40960 45056 49152 53248 57344 61440

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

279 / 621

配置之后,在交换机 S2 上,利用“show spanning-tree”命令,查看 STP 信息。

SW02#sh spanning-tree

VLAN0001

Spanning tree enabled protocol ieee

Root ID Priority 4097

Address aabb.cc00.3400

This bridge is the root !* 这是根桥

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 4097 (priority 4096 sys-id-ext 1)

Address aabb.cc00.3400

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Aging Time 300 sec

Interface Role Sts Cost Prio.Nbr Type

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

Et2/0 Desg FWD 100 128.9 Shr !* 根桥的口都是指定口

Et3/0 Desg FWD 100 128.13 Shr !* 根桥的口都是指定口

SW02#

3-1 观察根端口的选举

每个非根桥上,选举根端口的规则:

先比前往根桥的 Path Cost,越小越优先;

如果 Path Cost 相同,再比发送者的网桥 ID,越小越优先;

如果发送者的网桥 ID 相同,再比发送者的端口 ID,越小越优先。

根据拓扑,很容易判断。

配置之后,我们可以在交换机上,利用“show spanning-tree root”命令,查看根桥和根端口和根路径开销

(RPC)的信息。

SW01#sh spanning-tree root

Root Hello Max Fwd

Vlan Root ID Cost Time Age Dly Root Port

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

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

280 / 621

VLAN0001 4097 aabb.cc00.3400 100 2 20 15 Et2/0

SW01#

SW02#sh spanning-tree root

Root Hello Max Fwd

Vlan Root ID Cost Time Age Dly Root Port

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

VLAN0001 4097 aabb.cc00.3400 0 2 20 15 !* 注意:根桥上是不选根端口的!

SW02#

SW03#sh spanning-tree root

Root Hello Max Fwd

Vlan Root ID Cost Time Age Dly Root Port

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

VLAN0001 4097 aabb.cc00.3400 200 2 20 15 Et3/0

SW03#

SW04#sh spanning-tree root

Root Hello Max Fwd

Vlan Root ID Cost Time Age Dly Root Port

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

VLAN0001 4097 aabb.cc00.3400 100 2 20 15 Et3/0

SW04#

3-2 观察指定口的选举

注意指定口的选举规则:

根桥上的口都是指定口;

先比前往根桥的 Path Cost,越小越优先;

如果 Path Cost 相同,再比发送者的网桥 ID,越小越优先。

观察拓扑,很容易判断指定口的选举。

最后一句话,什么都没有选成的端口(也就是 AP 口)阻断掉!

至此,实验结束!

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

281 / 621

H7 华为实验 - STP

7.1 实验拓扑

7.2 配置步骤

1. 交换机 S1~S4 的初始化配置;

2. 观察 STP 的选举;

第一步:选举根网桥;

第二步:非根桥选举根端口;

第三步:每个网段选举指定口;

第四步:根端口和指定口为转发状态;其余端口(AP 口)为阻断状态。

3. 将 S2 配置为 VLAN 1 的根桥(root bridge);

观察根端口的选举;

观察指定口的选举;

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

282 / 621

7.3 配置参考

1 交换机 S1~S4 的初始化配置

首先在交换机 S1~S4 上,将不用的端口关闭,确保相关的端口开启。

注意:Huawei 的交换机默认启用的是 MST!

因此,需要在交换机上,利用“stp mode stp”命令,启用 STP 协议。

<Huawei>system-view

Enter system view, return user view with Ctrl+Z.

[Huawei]sysname SW01

[SW01]user-interface console 0

[SW01-ui-console0]idle-timeout 0 0

[SW01-ui-console0]quit

[SW01]

[SW01]port-group group-member g0/0/1 to g0/0/15

[SW01-port-group]shutdown

[SW01-port-group]quit

[SW01]port-group group-member g0/0/10 g0/0/12 to g0/0/14

[SW01-port-group]undo shutdown

[SW01-port-group]quit

[SW01]

[SW01]stp mode stp

[SW01]

<Huawei>system-view

Enter system view, return user view with Ctrl+Z.

[Huawei]sysname SW02

[SW02]user-interface console 0

[SW02-ui-console0]idle-timeout 0 0

[SW02-ui-console0]quit

[SW02]

[SW02]port-group group-member g0/0/1 to g0/0/15

[SW02-port-group]shutdown

[SW02-port-group]quit

[SW02]port-group group-member g0/0/10 g0/0/12

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

283 / 621

[SW02-port-group]undo shutdown

[SW02-port-group]quit

[SW02]

[SW02]stp mode stp

[SW02]

<Huawei>system-view

Enter system view, return user view with Ctrl+Z.

[Huawei]sysname SW03

[SW03]user-interface console 0

[SW03-ui-console0]idle-timeout 0 0

[SW03-ui-console0]quit

[SW03]

[SW03]port-group group-member g0/0/1 to g0/0/15

[SW03-port-group]shutdown

[SW03-port-group]quit

[SW03]port-group group-member g0/0/10 g0/0/12 to g0/0/13

[SW03-port-group]undo shutdown

[SW03-port-group]quit

[SW03]

[SW03]stp mode stp

[SW03]

<Huawei>system-view

Enter system view, return user view with Ctrl+Z.

[Huawei]sysname SW04

[SW04]user-interface console 0

[SW04-ui-console0]idle-timeout 0 0

[SW04-ui-console0]quit

[SW04]

[SW04]port-group group-member g0/0/1 to g0/0/15

[SW04-port-group]shutdown

[SW04-port-group]quit

[SW04]port-group group-member g0/0/10 g0/0/12 g0/0/14

[SW04-port-group]undo shutdown

[SW04-port-group]quit

[SW04]

[SW04]stp mode stp

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

284 / 621

[SW04]

非常简单!

2 观察 STP 的选举

注意:STP 协议在交换机上是默认启用的!华为的交换机默认启用的是 MST。

在查看这些交换机的 stp 属性之前,我们必须要回顾一下 STP 的选举过程和选举原则。

STP 的选举过程

步骤 选举 选举原则

1 每个网络选举唯一的根网桥 先比优先级,越小越优先;

如果优先级相同,再比网桥的 MAC 地址,越小越优先。

2 每个非根桥选举唯一的根端口 先比前往根桥的 Path Cost,越小越优先;

如果 Path Cost 相同,再比发送者的网桥 ID,越小越优先;

如果发送者的网桥 ID 相同,再比发送者的端口 ID,越小越优先。

3 每个网段选举唯一的指定端口 根桥上的口都是指定口;

先比前往根桥的 Path Cost,越小越优先;

如果 Path Cost 相同,再比发送者的网桥 ID,越小越优先。

4 确定端口状态 选举过程结束之后:

根端口和指定端口进入转发状态;

其余端口保持阻塞状态。

选举过程结束之后,根端口和指定端口进入转发状态;其余端口进入阻塞状态。

了解以上信息之后,查看这些交换机的 STP 信息。

2-1 第一步:选举根网桥

我们来看这四个交换机,哪个应该成为根网桥?

注意:你需要拿出笔和纸,在纸上画出网络拓扑,并且记载后面命令的输出结果!因为,每个交换机的

MAC 地址是不一样的!

呵呵,不许偷懒!

在 S1~S4 上,利用“display stp brief ”查看端口状态,或者利用“display stp”命令,查看 STP 详细信息。

下面,在交换机 S1 上,用这两个命令,展示一下。

[SW01]dis stp brief

MSTID Port Role STP State Protection

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

285 / 621

0 GigabitEthernet0/0/10 DESI FORWARDING NONE

0 GigabitEthernet0/0/12 DESI FORWARDING NONE

0 GigabitEthernet0/0/13 DESI FORWARDING NONE

0 GigabitEthernet0/0/14 DESI FORWARDING NONE

[SW01]

[SW01]dis stp

-------[CIST Global Info][Mode STP]------- !* STP 模式(STP 就是标准生成树)

CIST Bridge :32768.4c1f-cc37-0a0e !* 网桥 ID

Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 !* 计时器

Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20

CIST Root/ERPC :32768.4c1f-cc37-0a0e / 0 !* 根桥 ID/RPC(跟路径开销)

CIST RegRoot/IRPC :32768.4c1f-cc37-0a0e / 0

CIST RootPortId :0.0

BPDU-Protection :Disabled

TC or TCN received :23

TC count per hello :0

STP Converge Mode :Normal

Time since last TC :0 days 0h:16m:4s

Number of TC :32

Last TC occurred :GigabitEthernet0/0/14

----[Port1(GigabitEthernet0/0/1)][DOWN]----

Port Protocol :Enabled

Port Role :Disabled Port

Port Priority :128

Port Cost(Dot1T ) :Config=auto / Active=200000000

Designated Bridge/Port :32768.4c1f-cc37-0a0e / 128.1

Port Edged :Config=default / Active=disabled

Point-to-point :Config=auto / Active=false

Transit Limit :147 packets/hello-time

Protection Type :None

---- More ----

下面,在交换机 S2~S4 上,利用“display stp”命令,查看 BID。

[SW02]dis stp

-------[CIST Global Info][Mode STP]-------

CIST Bridge :32768.4c1f-cc38-5e28 !* 桥 ID

Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

286 / 621

Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20

CIST Root/ERPC :32768.4c1f-cc37-0a0e / 20000 !* 根 ID / RPC

CIST RegRoot/IRPC :32768.4c1f-cc38-5e28 / 0

CIST RootPortId :128.10

BPDU-Protection :Disabled

TC or TCN received :135

TC count per hello :0

STP Converge Mode :Normal

Time since last TC :0 days 0h:21m:50s

Number of TC :35

Last TC occurred :GigabitEthernet0/0/10

----[Port1(GigabitEthernet0/0/1)][DOWN]----

Port Protocol :Enabled

Port Role :Disabled Port

Port Priority :128

Port Cost(Dot1T ) :Config=auto / Active=200000000

Designated Bridge/Port :32768.4c1f-cc38-5e28 / 128.1

Port Edged :Config=default / Active=disabled

Point-to-point :Config=auto / Active=false

Transit Limit :147 packets/hello-time

Protection Type :None

---- More ----

[SW03]dis stp

-------[CIST Global Info][Mode STP]-------

CIST Bridge :32768.4c1f-ccc8-3fec !* 桥 ID

Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20

Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20

CIST Root/ERPC :32768.4c1f-cc37-0a0e / 20000 !* 根 ID / RPC

CIST RegRoot/IRPC :32768.4c1f-ccc8-3fec / 0

CIST RootPortId :128.12

BPDU-Protection :Disabled

TC or TCN received :333

TC count per hello :0

STP Converge Mode :Normal

Time since last TC :0 days 0h:22m:48s

Number of TC :40

Last TC occurred :GigabitEthernet0/0/12

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

287 / 621

----[Port1(GigabitEthernet0/0/1)][DOWN]----

Port Protocol :Enabled

Port Role :Disabled Port

Port Priority :128

Port Cost(Dot1T ) :Config=auto / Active=200000000

Designated Bridge/Port :32768.4c1f-ccc8-3fec / 128.1

Port Edged :Config=default / Active=disabled

Point-to-point :Config=auto / Active=false

Transit Limit :147 packets/hello-time

Protection Type :None

---- More ----

[SW04]dis stp

-------[CIST Global Info][Mode STP]-------

CIST Bridge :32768.4c1f-cc39-4698 !* 桥 ID

Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20

Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20

CIST Root/ERPC :32768.4c1f-cc37-0a0e / 20000 !* 跟 ID / RPC

CIST RegRoot/IRPC :32768.4c1f-cc39-4698 / 0

CIST RootPortId :128.14

BPDU-Protection :Disabled

TC or TCN received :246

TC count per hello :0

STP Converge Mode :Normal

Time since last TC :0 days 0h:24m:10s

Number of TC :27

Last TC occurred :GigabitEthernet0/0/14

----[Port1(GigabitEthernet0/0/1)][DOWN]----

Port Protocol :Enabled

Port Role :Disabled Port

Port Priority :128

Port Cost(Dot1T ) :Config=auto / Active=200000000

Designated Bridge/Port :32768.4c1f-cc39-4698 / 128.1

Port Edged :Config=default / Active=disabled

Point-to-point :Config=auto / Active=false

Transit Limit :147 packets/hello-time

Protection Type :None

---- More ----

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

288 / 621

我们看到:

S1 的 BID:32768.4c1f-cc37-0a0e;

S2 的 BID:32768.4c1f-cc38-5e28;

S3 的 BID:32768.4c1f-ccc8-3fec;

S4 的 BID:32768.4c1f-cc39-4698。

注意:选择网桥 ID 最小的为根网桥,先比较优先级最小,再比较 MAC 地址最小。

所以,S1 成为根网桥!

2-2 第二步:非根桥选举根端口

既然交换机 S1 成为根桥,那么交换机 S2,S3 和 S4 就是非根桥。

注意:每个非根桥上选举唯一的根端口。先比前往根桥的 Path Cost,越小越优先!

思科交换机的生成树的 Cost 值默认为【原始】;华为交换机的生成树的 Cost 值默认为【ieee 802.1t】。

带宽 原始(旧) 802.1t(新)

10M 100 2,000,000

100M 19 200,000

1,000M 4 20,000

10,000M 2 2,000

先看交换机 S2

[SW02]dis stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/10 ROOT FORWARDING NONE !* 根端口

0 GigabitEthernet0/0/12 DESI FORWARDING NONE

[SW02]

[SW03]dis stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/10 ALTE DISCARDING NONE

0 GigabitEthernet0/0/12 ROOT FORWARDING NONE !* 根端口

0 GigabitEthernet0/0/13 ALTE DISCARDING NONE

[SW03]

[SW04]dis stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/10 DESI FORWARDING NONE

0 GigabitEthernet0/0/12 ALTE DISCARDING NONE

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

289 / 621

0 GigabitEthernet0/0/14 ROOT FORWARDING NONE !* 根端口

[SW04]

注意:每个非根桥上选举唯一的根端口。先比前往根桥的 Path Cost,越小越优先!

2-3 第三步:每个网段选举指定口

接下来,每个网段选举一个指定口。

注意,指定口的选举规则:

根桥上的口都是指定口;

先比前往根桥的 Path Cost,越小越优先;

如果 Path Cost 相同,再比发送者的网桥 ID,越小越优先。

观察拓扑,即可。

2-4 第四步:根端口和指定口为转发状态;其余端口(AP 口)为阻断状态。

观察拓扑即可知道,交换机 S3 的 G0/0/10 和 G0/0/13,交换机 S4 的 G0/0/12 成为阻塞端口(AP 口)。

[SW03]dis stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/10 ALTE DISCARDING NONE

0 GigabitEthernet0/0/12 ROOT FORWARDING NONE

0 GigabitEthernet0/0/13 ALTE DISCARDING NONE

[SW03]

[SW04]dis stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/10 DESI FORWARDING NONE

0 GigabitEthernet0/0/12 ALTE DISCARDING NONE

0 GigabitEthernet0/0/14 ROOT FORWARDING NONE

[SW04]

告一段落!

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

290 / 621

3 将 S2 配置为 VLAN 1 的根桥(root bridge)

接下来,我们改变交换机 S2 的优先级(将默认优先级 32768 改为 4096),让交换机 S2 成为根桥。

[SW02]stp priority 4096

注意:网桥优先级的取值范围必须是 4096 的整数倍:

% Allowed values are:

0 4096 8192 12288 16384 20480 24576 28672

32768 36864 40960 45056 49152 53248 57344 61440

配置之后,在交换机 S2 上,利用“show stp”命令,查看 STP 信息。

[SW02]dis stp

-------[CIST Global Info][Mode STP]-------

CIST Bridge :4096 .4c1f-cc38-5e28 !* 桥 ID

Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20

Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20

CIST Root/ERPC :4096 .4c1f-cc38-5e28 / 0 !* 根 ID / RPC

CIST RegRoot/IRPC :4096 .4c1f-cc38-5e28 / 0

CIST RootPortId :0.0

BPDU-Protection :Disabled

TC or TCN received :136

TC count per hello :0

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

291 / 621

STP Converge Mode :Normal

Time since last TC :0 days 0h:6m:49s

Number of TC :36

Last TC occurred :GigabitEthernet0/0/12

----[Port1(GigabitEthernet0/0/1)][DOWN]----

Port Protocol :Enabled

Port Role :Disabled Port

Port Priority :128

Port Cost(Dot1T ) :Config=auto / Active=200000000

Designated Bridge/Port :4096.4c1f-cc38-5e28 / 128.1

Port Edged :Config=default / Active=disabled

Point-to-point :Config=auto / Active=false

Transit Limit :147 packets/hello-time

Protection Type :None

---- More ----

配置之后,在交换机 S2 上,利用“show stp brief”命令,查看 STP 信息。

[SW02]dis stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/10 DESI FORWARDING NONE !* 根桥上的口都是指定口

0 GigabitEthernet0/0/12 DESI FORWARDING NONE !* 根桥上的口都是指定口

[SW02]

3-1 观察根端口的选举

每个非根桥上,选举根端口的规则:

先比前往根桥的 Path Cost,越小越优先;

如果 Path Cost 相同,再比发送者的网桥 ID,越小越优先;

如果发送者的网桥 ID 相同,再比发送者的端口 ID,越小越优先。

根据拓扑,很容易判断。

配置之后,我们可以在交换机上,利用“show spanning-tree root”命令,查看根桥和根端口和根路径开销

(RPC)的信息。

[SW01]dis stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/10 ROOT FORWARDING NONE

0 GigabitEthernet0/0/12 DESI FORWARDING NONE

0 GigabitEthernet0/0/13 DESI FORWARDING NONE

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

292 / 621

0 GigabitEthernet0/0/14 DESI FORWARDING NONE

[SW01]

[SW03]dis stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/10 ALTE DISCARDING NONE

0 GigabitEthernet0/0/12 ROOT FORWARDING NONE

0 GigabitEthernet0/0/13 ALTE DISCARDING NONE

[SW03]

[SW04]dis stp brief

MSTID Port Role STP State Protection

0 GigabitEthernet0/0/10 DESI FORWARDING NONE

0 GigabitEthernet0/0/12 ROOT FORWARDING NONE

0 GigabitEthernet0/0/14 ALTE DISCARDING NONE

[SW04]

3-2 观察指定口的选举

注意指定口的选举规则:

根桥上的口都是指定口;

先比前往根桥的 Path Cost,越小越优先;

如果 Path Cost 相同,再比发送者的网桥 ID,越小越优先。

观察拓扑,很容易判断指定口的选举。

最后一句话,什么都没有选成的端口(也就是 AP 口)阻断掉!

至此,实验结束!

科迪网络 www.TechNow.cn TechNow CCNA (HCIA) 路由交换配置指南 v11

293 / 621

思科 vs 华为:STP

Cisco IOS Huawei VRP

改变 STP 的模式

Switch(config)#spanning-tree mode pvst

Switch(config)#spanning-tree mode rapid-pvst

Switch(config)#spanning-tree mode mst

[huawei]stp mode stp

[huawei]stp mode rstp

[huawei]stp mode mstp

改变网桥的优先级

Switch(config)#spanning-tree vlan 1 priority 4096

% Bridge Priority must be in increments of 4096.

[huawei]stp priority 4096

[Huawei]stp priority ?

INTEGER<0-61440> Bridge priority, in steps of 4096

关于 root primary 和 root secondary

Switch(config)#spanning-tree vlan 1 root primary

Switch(config)#spanning-tree vlan 1 root secondary

root primary:现有根的优先级 - 4096 - 4096

root secondary:现有根的优先级 - 4096

[huawei]stp root primary

[huawei]stp root secondary

root primary: priority = 0

root secondary:priority = 4096

STP 接口的配置

Switch(config)#int e0/1

Switch(config-if)#spanning-tree cost 111

Switch(config-if)#spanning-tree port-priority 64

Switch(config-if)#spanning-tree port-priority ?

<0-192> port priority in increments of 64

[Huawei]int gi0/0/10

[Huawei-GigabitEthernet0/0/13]stp cost 111

[Huawei-GigabitEthernet0/0/13]stp port priority 64

[Huawei-GigabitEthernet0/0/10]stp port priority ?

INTEGER<0-240> Port priority, in steps of 16

验证

Switch#show spanning-tree

Switch#show spanning-tree vlan 10

Switch#show spanning-tree root

Switch#show spanning-tree bridge

[Huawei]display stp

[Huawei]display stp brief