文章目录
1.1 实验二:生成树基础实验
1.1.1 实验介绍
1.1.1.1 关于本实验
以太网交换网络中为了进行链路备份,提高网络可靠性,通常会使用冗余链路。但是使用冗余链路会在交换网络上产生环路,引发广播风暴以及MAC地址表不稳定等故障现象,从而导致用户通信质量较差,甚至通信中断。为解决交换网络中的环路问题,提出了生成树协议STP( Spanning Tree Protocol )。
与众多协议的发展过程一样,生成树协议也是随着网络的发展而不断更新的,从最初的IEEE802.1D中定义的STP到IEEE802.1W中定义的快速生成树协议RSTP (Rapid Spanning Tree Protocol),再到最新的IEEE802.1S中定义的多生成树协议MSTP (Multiple Spanning Tree Protocol )。
本实验将通过完成STP的基本配置,帮助学员掌握STP的配置和原理,以及部分RSTP特性。
1.1.1.2 实验目的
- 掌握启用和禁用STP/RSTP的方法
- 掌握修改交换机STP模式的方法
- 掌握修改桥优先级,控制根桥选举的方法
- 掌握修改端口优先级,控制根端口和指定端口选举的方法
- 掌握修改端口开销,控制根端口和指定端口选举的方法
- 掌握边缘端口的配置方法
- 掌握启用和禁用RSTP的配置方法
1.1.1.3 实验组网介绍
生成树基础拓扑图
1.1.1.4 实验背景
某公司的二层交换网络中,为了提高网络可靠性,故在二层交换网络中增加冗余链路。为了阻止冗余链路可能带来的广播风暴,MAC地址漂移等负面影响,需要在交换机之间部署生成树协议。
1.1.2 实验任务配置
1.1.2.1 配置思路
1.使能设备上的STP功能
2.修改桥优先级来控制根桥的选举
3.修改接口参数来控制端口角色
4.修改设备运行RSTP协议
5.配置RSTP边缘端口
1.1.2.2 配置步骤
步骤1关闭多余接口
只针对《HCIA-Datacom实验室搭建指南V1.0》所描述的环境,其他环境可以忽略此步骤。
# 关闭S1与S2之间的GigabitEthernet0/0/12接口
[S1]interface GigabitEthernet 0/0/12
[S1]shutdown
[S2]interface GigabitEthernet 0/0/12
[S2]shutdown
步骤2 配置设备运行STP
# 全局使能STP功能
<S1>system-view
Enter system view, return user view with Ctrl+Z.
[S1]stp enable
stp enable命令用来使能交换设备或端口上的STP/RSTP/MSTP功能。缺省情况下,交换设备上的STP/RSTP/MSTP功能处于启用状态,此处配置仅为演示用。
# 修改当前生成树工作模式为STP
[S1]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment...done.
stp mode{mstp | rstp | stp} 命令用来配置交换设备的生成树协议工作模式。缺省情况下,设备的生成树协议工作模式为MSTP模式。当前设备的生成树模式已经被修改为STP。
[S2]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment...done.
[S3]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment...done.
[S4]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment...done.
# 查看生成树的状态,以S1为例
[S1]display stp
-------[CIST Global Info][Mode MSTP]-------
CIST Bridge :32768.4c1f-cce2-1bfd
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-cc4b-4ee3 / 20000
CIST RegRoot/IRPC :32768.4c1f-cce2-1bfd / 0
CIST RootPortId :128.13
BPDU-Protection :Disabled
TC or TCN received :13
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:1m:13s
Number of TC :5
Last TC occurred :GigabitEthernet0/0/13
显示信息还包括各个接口的状态,在上述输出中已经按ctrl+c结束显示。
# 查看各交换机上生成树的状态信息摘要。
[S1]display stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/10 ALTE DISCARDING NONE
0 GigabitEthernet0/0/11 ALTE DISCARDING NONE
0 GigabitEthernet0/0/13 ROOT FORWARDING NONE
0 GigabitEthernet0/0/14 ALTE DISCARDING NONE
[S2]display stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/10 DESI FORWARDING NONE
0 GigabitEthernet0/0/11 DESI FORWARDING NONE
0 GigabitEthernet0/0/13 ROOT FORWARDING NONE
0 GigabitEthernet0/0/14 DESI FORWARDING NONE
[S3]display stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 DESI FORWARDING NONE
0 GigabitEthernet0/0/2 DESI FORWARDING NONE
0 GigabitEthernet0/0/3 DESI FORWARDING NONE
[S4]display stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 DESI FORWARDING NONE
0 GigabitEthernet0/0/2 ALTE DISCARDING NONE
0 GigabitEthernet0/0/3 ROOT FORWARDING NONE
步骤3 修改设备参数,使得S1成为根桥,S2成为备份根桥
# 修改S1和S2的桥优先级
[S1]stp root primary
# 在S1上查看当前STP状态
[S1]display stp
-------[CIST Global Info][Mode MSTP]-------
CIST Bridge :0 .4c1f-cce2-1bfd
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :0 .4c1f-cce2-1bfd / 0
CIST RegRoot/IRPC :0 .4c1f-cce2-1bfd / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
CIST Root Type :Primary root
TC or TCN received :37
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:0m:44s
Number of TC :13
Last TC occurred :GigabitEthernet0/0/11
此时自身桥ID与根桥ID相同,且根路径开销为0,说明SI是当前网络的根桥。
# 在所有设备上查看STP状态摘要
[S1]display stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/10 DESI FORWARDING NONE
0 GigabitEthernet0/0/11 DESI FORWARDING 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/10 ROOT FORWARDING NONE
0 GigabitEthernet0/0/11 ALTE DISCARDING NONE
0 GigabitEthernet0/0/13 DESI FORWARDING NONE
0 GigabitEthernet0/0/14 DESI FORWARDING NONE
[S3]display stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 ROOT FORWARDING NONE
0 GigabitEthernet0/0/2 ALTE DISCARDING NONE
0 GigabitEthernet0/0/3 DESI FORWARDING NONE
[S4]display stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 ROOT FORWARDING NONE
0 GigabitEthernet0/0/2 ALTE DISCARDING NONE
0 GigabitEthernet0/0/3 ALTE DISCARDING NONE
步骤4 修改设备参数,使得S3的GigabitEthernet0/0/2接口成为根端口
# 查看S3上的STP状态信息
[S3]display stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.4c1f-cc65-1ffc
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :0 .4c1f-ccaf-3c65 / 20000
CIST RegRoot/IRPC :32768.4c1f-cc65-1ffc / 0
CIST RootPortId :128.1
BPDU-Protection :Disabled
TC or TCN received :802
TC count per hello :1
STP Converge Mode :Normal
Time since last TC :0 days 0h:0m:56s
Number of TC :46
Last TC occurred :GigabitEthernet0/0/1
当前S4到S1的根路径开销为2000。
[S3]interface GigabitEthernet 0/0/1
[S3-GigabitEthernet0/0/1]stp cost 5000
# 查看当前STP状态信息摘要
[S3]display stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 ROOT FORWARDING NONE
0 GigabitEthernet0/0/2 DESI FORWARDING NONE
0 GigabitEthernet0/0/3 DESI FORWARDING NONE