HCNA网络技术
上QQ阅读APP看本书,新人免费读10天
设备和账号都新为新人

2.6 实训二 生成树协议STP配置

1.实验目的

掌握启用和关闭STP的方法;了解不同STP模式的差异;掌握修改网桥优先级影响根网桥选举的方法;掌握修改端口优先级影响根端口与指定端口选举的方法;掌握配置边缘端口的方法。

2.实验拓扑

生成树拓扑如图2-37所示。

图2-37 生成树拓扑

3.配置步骤

step1:STP配置。

实验之前,关闭S3的接口E0/0/1,以避免对实验的影响。请保证设备以空配置启动,如果设备默认生成树没有开启,使用stp enable命令开启。本次实验使用传统生成树。

<Quidway>system-view

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

[Quidway]sysname S1

[S1]stp mode stp

[S1]stp root secondary

===========================================

<Quidway>system-view

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

[Quidway]sysname S2

[S2]stp mode stp

[S2]stp root primary

===========================================

<Quidway>system-view

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

[Quidway]sysname S3

[S3]stp mode stp

===========================================

<Quidway>system-view

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

[Quidway]sysname S4

[S4]stp mode stp

使用display stp brief命令查看各接口简要STP状态。

[S1]display stp brief

MSTID  Port            Role    STP State       Protection

0     GigabitEthernet0/0/9    ROOT   FORWARDING   NONE

0     GigabitEthernet0/0/10   ALTE   DISCARDING    NONE

0     GigabitEthernet0/0/13   DESI   FORWARDING   NONE

0     GigabitEthernet0/0/14   DESI   FORWARDING   NONE

[S2]display stp brief

MSTID  Port            Role    STP State       Protection

0     GigabitEthernet0/0/9    DESI   FORWARDING   NONE

0     GigabitEthernet0/0/10   DESI   FORWARDING   NONE

0     GigabitEthernet0/0/23   DESI   FORWARDING   NONE

0     GigabitEthernet0/0/24   DESI   FORWARDING   NONE

[S3]display stp brief

MSTID  Port            Role    STP State       Protection

0     Ethernet0/0/13       ALTE   DISCARDING    NONE

0     Ethernet0/0/23       ROOT   FORWARDING   NONE

[S4]display stp brief

MSTID  Port            Role    STP State       Protection

0     Ethernet0/0/14       ALTE   DISCARDING    NONE

0     Ethernet0/0/24       ROOT   FORWARDING   NONE

使用display stp interface命令查看某接口详细STP状态。

[S1]display stp interface GigabitEthernet 0/0/10

----[CIST][Port10(GigabitEthernet0/0/10)][DISCARDING]---

Port Protocol :enabled

Port Role :Alternate Port

Port Priority :128

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

Desg.Bridge/Port :0.0018-82e1-aea6 / 128.10

Port Edged :Config=default / Active=disabled

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

Transit Limit :147 packets/hello-time

Protection Type :None

Port Stp Mode :STP

Port Protocol Type :Config=auto / Active=dot1s

PortTimes :Hello 2s MaxAge 20s FwDly 15s RemHop 0

TC or TCN send :2

TC or TCN received :64

BPDU Sent :24

TCN:0,Config:0,RST:24,MST:0

BPDU Received :350601

TCN:0,Config:0,RST:350601,MST:0

step2:根网桥选举控制。

使用display stp命令查看当前根网桥消息。

[S2]display stp

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

CIST Bridge :0 .0018-82e1-aea6

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

CIST Root/ERPC :0 .0018-82e1-aea6 / 0

CIST RegRoot/IRPC :0 .0018-82e1-aea6 / 0

CIST RootPortId :0.0

BPDU-Protection :disabled

CIST Root Type :PRIMARY root

TC or TCN received :41

TC count per hello :0

STP Converge Mode :Nomal

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

······output omit······

实验中特别定义了S2为主根网桥,S1为备份根网桥。如上输出“CIST Bridge”“CIST Root/ERPC”字段值相同的即为根网桥。

桥优先级数值越小的优先级越高,因此将S1的桥优先级修改为4096,将S2的桥优先级修改为8192,S1的优先级高于S2,S1将选举为根网桥。

[S1]undo stp root

[S1]stp priority 4096

[S2]undo stp root

[S2]stp priority 8192

使用display stp命令查看新的根网桥信息。

[S1]display stp

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

CIST Bridge :4096 .0018-82e1-aea6

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

CIST Root/ERPC :4096 .0018-82e1-aea6 / 0

CIST RegRoot/IRPC :4096 .0018-82e1-aea6 / 0

CIST RootPortId :0.0

BPDU-Protection :disabled

TC or TCN received :62

TC count per hello :0

STP Converge Mode :Nomal

Time since last TC :0 days 0h:0m:3s

······output omit······

[S2]display stp

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

CIST Bridge :8192 .0018-82e1-ae82

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

CIST Root/ERPC :4096 .0018-82e1-aea6 / 20000

CIST RegRoot/IRPC :8192 .0018-82e1-ae82 / 0

CIST RootPortId :128.9

BPDU-Protection :disabled

TC or TCN received :174

TC count per hello :2

STP Converge Mode :Nomal

Time since last TC :0 days 0h:0m:1s

······output omit······

由以上输出可以看出,S1成为了新的根网桥。关闭S1上的G0/0/9、G0/0/10、G0/0/13、G0/0/14四个接口达到隔离S1的目的。

[S1]interface GigabitEthernet 0/0/9

[S1-GigabitEthernet0/0/9]shutdown

[S1-GigabitEthernet0/0/9]interface GigabitEthernet 0/0/10

[S1-GigabitEthernet0/0/10]shutdown

[S1-GigabitEthernet0/0/10]interface GigabitEthernet 0/0/13

[S1-GigabitEthernet0/0/13]shutdown

[S1-GigabitEthernet0/0/13]interface GigabitEthernet 0/0/14

[S1-GigabitEthernet0/0/14]shutdown

[S2]display stp

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

CIST Bridge :8192 .0018-82e1-ae82

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

CIST Root/ERPC :8192 .0018-82e1-ae82 / 0

CIST RegRoot/IRPC :8192 .0018-82e1-ae82 / 0

CIST RootPortId :0.0

BPDU-Protection :disabled

TC or TCN received :197

TC count per hello :0

STP Converge Mode :Nomal

Time since last TC :0 days 0h:0m:3s

······output omit······

由以上粗体字部分可以看出,在S1失效的情况下,S2由备份根网桥成为了根网桥。

开启S1之前关闭的接口。

[S1]interface GigabitEthernet 0/0/9

[S1-GigabitEthernet0/0/9]undo shutdown

[S1-GigabitEthernet0/0/9]interface GigabitEthernet 0/0/10

[S1-GigabitEthernet0/0/10]undo shutdown

[S1-GigabitEthernet0/0/10]interface GigabitEthernet 0/0/13

[S1-GigabitEthernet0/0/13]undo shutdown

[S1-GigabitEthernet0/0/13]interface GigabitEthernet 0/0/14

[S1-GigabitEthernet0/0/14]undo shutdown

[S1]display stp

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

CIST Bridge :4096 .0018-82e1-aea6

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

CIST Root/ERPC :4096 .0018-82e1-aea6 / 0

CIST RegRoot/IRPC :4096 .0018-82e1-aea6 / 0

CIST RootPortId :0.0

BPDU-Protection :disabled

TC or TCN received :63

TC count per hello :0

STP Converge Mode :Nomal

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

······output omit······

[S2]display stp

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

CIST Bridge :8192 .0018-82e1-ae82

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

CIST Root/ERPC :4096 .0018-82e1-aea6 / 20000

CIST RegRoot/IRPC :8192 .0018-82e1-ae82 / 0

CIST RootPortId :128.9

BPDU-Protection :disabled

TC or TCN received :251

TC count per hello :0

STP Converge Mode :Nomal

Time since last TC :0 days 0h:0m:1s

······output omit······

由以上输出可以看出,当S1恢复后重新被选举成为根网桥。

step3:根端口选举控制。

在S2上使用display stp brief查看当前接口的角色信息。

[S2]display stp brief

MSTID  Port            Role    STP State       Protection

0     GigabitEthernet0/0/9    ROOT   FORWARDING   NONE

0     GigabitEthernet0/0/10   ALTE   DISCARDING    NONE

0     GigabitEthernet0/0/23   DESI   FORWARDING   NONE

0     GigabitEthernet0/0/24   DESI   FORWARDING   NONE

此时,G0/0/9为根端口,G0/0/10为替代端口,将在下面通过修改S1端口优先级的方式实现S2端口G0/0/10成为根端口,G0/0/9成为替代端口。

修改S1接口G0/0/9和G0/0/10的端口优先级。端口优先级默认值为128,数值越大优先级越小,因此在下面实验中将S1的接口G0/0/9端口优先级设置为32,G0/0/10端口优先级设置为16,这样S1的接口G0/0/10优先级高于G0/0/9,S2的接口G0/0/10将选举成为新的根端口。

[S1]interface GigabitEthernet 0/0/9

[S1-GigabitEthernet0/0/9]stp port priority 32

[S1-GigabitEthernet0/0/9]interface GigabitEthernet 0/0/10

[S1-GigabitEthernet0/0/10]stp port priority 16

提示:此处是修改S1的端口优先级,而不是修改S2的端口优先级。

[S1]display stp interface GigabitEthernet 0/0/9

----[CIST][Port9(GigabitEthernet0/0/9)][FORWARDING]---

Port Protocol :enabled

Port Role :Designated Port

Port Priority :32

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

Desg.Bridge/Port :4096.0018-82e1-aea6 / 32.9

Port Edged :Config=default / Active=disabled

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

Transit Limit :147 packets/hello-time

Protection Type :None

Port Stp Mode :STP

Port Protocol Type :Config=auto / Active=dot1s

PortTimes :Hello 2s MaxAge 20s FwDly 15s RemHop 20

TC or TCN send :0

TC or TCN received :0

BPDU Sent :229

TCN:0,Config:229,RST:0,MST:0

BPDU Received :3

TCN:1,Config:2,RST:0,MST:0

[S1]display stp interface GigabitEthernet 0/0/10

----[CIST][Port10(GigabitEthernet0/0/10)][FORWARDING]---

Port Protocol :enabled

Port Role :Designated Port

Port Priority :16

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

Desg.Bridge/Port :4096.0018-82e1-aea6 / 16.10

Port Edged :Config=default / Active=disabled

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

Transit Limit :147 packets/hello-time

Protection Type :None

Port Stp Mode :STP

Port Protocol Type :Config=auto / Active=dot1s

PortTimes :Hello 2s MaxAge 20s FwDly 15s RemHop 20

TC or TCN send :0

TC or TCN received :0

BPDU Sent :210

TCN:0,Config:210,RST:0,MST:0

BPDU Received :3

TCN:1,Config:2,RST:0,MST:0

在S2上使用display stp brief查看当前接口的角色信息。

[S2]display stp brief

MSTID  Port            Role    STP State       Protection

0     GigabitEthernet0/0/9    ALTE   DISCARDING    NONE

0     GigabitEthernet0/0/10   ROOT   FORWARDING   NONE

0     GigabitEthernet0/0/23   DESI   FORWARDING   NONE

0     GigabitEthernet0/0/24   DESI   FORWARDING   NONE

由上输出可以看出,S2的接口G0/0/10被选举成了新的根端口,G0/0/9成了替代端口。关闭S2上的根端口G0/0/10,观察替代端口选举为新的根端口情况。

[S2]interface GigabitEthernet 0/0/10

[S2-GigabitEthernet0/0/10]shutdown

<S2>display stp brief

MSTID  Port            Role    STP State       Protection

0     GigabitEthernet0/0/9    ROOT   FORWARDING   NONE

0     GigabitEthernet0/0/23   DESI   FORWARDING   NONE

0     GigabitEthernet0/0/24   DESI   FORWARDING   NONE

此时G0/0/9被选举成为了新的根端口。

step4:边缘端口配置。

将连接用户终端设备如计算机的端口配置成边缘端口,可以使该端口无须经历STP计算过程快速进入转发状态。本任务中,仅示例将S3接口E0/0/3、E0/0/4配置成边缘端口,实际网络中可以根据需要配置。

[S3]interface Ethernet0/0/3

[S3-Ethernet0/0/3]stp edged-port enable

[S3-Ethernet0/0/3]interface Ethernet0/0/4

[S3-Ethernet0/0/4]stp edged-port enable

配置完成后可以将计算机网线接入到S3的E0/0/3,在S3上使用display stp brief命令查看端口状态。由于E0/0/2是边缘端口,发现端口立刻就转变到“Forwarding”状态了。

而连接到其他没有配置边缘端口的如E0/0/5接口,则在链路UP之后要等待约30s才能达到“Forwarding”状态。