【ensp实验配置】生成树配置实验

张开发
2026/4/16 10:06:42 15 分钟阅读

分享文章

【ensp实验配置】生成树配置实验
一、实验目的掌握启用和禁用STP/RSTP的方法掌握修改交换机STP模式的方法掌握修改桥优先级控制根桥选举的方法掌握修改端口优先级控制根端口和指定端口选举的方法掌握修改端口开销控制根端口和指定端口选举的方法掌握边缘端口的配置方法掌握启用和禁用RSTP的配置方法二、实验组网介绍和背景说明某公司的二层交换网络中为了提高网络可靠性故在二层交换网络中增加冗余链路。为了阻止冗余链路可能带来的广播风暴MAC地址漂移等负面影响需要在交换机之间部署生成树协议。说明由于交换机的MAC地址不同STP的计算结果在不同的物理环境中会有所不同请以您使用的组网环境为准。三、配置思路使能设备上的STP功能修改桥优先级来控制根桥的选举修改接口参数来控制端口角色修改设备运行RSTP协议配置RSTP边缘端口如果你想要学习更多网络配置案例或者深入学习网络技术这里直接找我领取学习资料领取方式文末左下角直接找我或评论区666告诉我学习教程实验案例四、配置步骤步骤1 关闭多余接口#关闭S1、S2、S3、S4的接口[S1] interface GE 1/0/1[S1-GE1/0/1] shutdown[S1-GE1/0/1] quit[S1] interface GE 1/0/10[S1-GE1/0/10] shutdown[S1-GE1/0/10] quit[S2] interface GE 1/0/1[S2-GE1/0/1] shutdown[S2-GE1/0/1] quit[S2] interface GE 1/0/10[S2-GE1/0/10] shutdown[S2-GE1/0/10] quit[S3] interface GE 1/0/4[S3-GE1/0/4] shutdown[S3-GE1/0/4] quit[S4] interface GE 1/0/4[S4-GE1/0/4] shutdown[S4-GE1/0/4] quit步骤 2配置设备运行STP# 全局使能STP功能[S1] stp enablestp enable命令用来使能交换设备或端口上的STP/RSTP/MSTP功能。缺省情况下交换设备上的STP功能处于启用状态。# 修改当前生成树工作模式为STP[S1] stp mode stpstp mode {mstp | rstp | stp}命令用来配置交换设备的生成树协议工作模式。缺省情况下设备的生成树工作模式为MSTP模式。当前设备的生成树模式已经被修改为STP。[S2] stp mode stp[S3] stp mode stp[S4] stp mode stp# 查看生成树的状态以S1为例[S1] display stpCIST Global Information:Mode :STPCIST Bridge :32768.20df-73f5-44e1 //本设备的桥IDConfig Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20CIST Root/ERPC :32768.20df-73f5-4331 / 20000 //根桥的桥ID和到根桥的CostCIST RegRoot/IRPC :32768.20df-73f5-44e1 / 0 (This bridge is the root)CIST RootPortId :128.14 (GE1/0/14)BPDU-Protection :DisabledTC or TCN received :45TC count per hello :1STP Converge Mode :NormalShare region-configuration :EnabledTime since last TC :0 days 0h:0m:31sNumber of TC :16Last TC occurred :GE1/0/14Topo Change Flag :0显示信息还包括各个接口的状态在上述输出中已经按CtrlC结束显示。# 查看各交换机上生成树的状态信息摘要[S1] display stp briefMSTID Port Role STP State Protection Cost Edged0 GE1/0/11 DESI forwarding none 20000 disable0 GE1/0/12 DESI forwarding none 20000 disable0 GE1/0/13 ALTE discarding none 20000 disable0 GE1/0/14 ROOT forwarding none 20000 disable[S2] display stp briefMSTID Port Role STP State Protection Cost Edged0 GE1/0/11 ALTE discarding none 20000 disable0 GE1/0/12 ALTE discarding none 20000 disable0 GE1/0/13 ALTE discarding none 20000 disable0 GE1/0/14 ROOT forwarding none 20000 disable[S3] display stp briefMSTID Port Role STP State Protection Cost Edged0 GE1/0/1 DESI forwarding none 20000 disable0 GE1/0/2 DESI forwarding none 20000 disable0 GE1/0/3 ROOT forwarding none 20000 disable[S4] display stp briefMSTID Port Role STP State Protection Cost Edged0 GE1/0/1 DESI forwarding none 20000 disable0 GE1/0/2 DESI forwarding none 20000 disable0 GE1/0/3 DESI forwarding none 20000 disable# 综合根桥ID信息以及各个交换机上的端口信息可得当前拓扑如下虚线代表该链路不转发业务数据。注该拓扑仅供参考不一定与实际实验环境中的生成树拓扑相同。步骤 3修改设备参数使得S1成为根桥S2成为备份根桥# 修改S1和S2的桥优先级[S1] stp root primary由于根桥在网络中的重要性在根桥选举过程中通常希望性能高、网络层次高的交换设备被选举为根桥。但是性能高、网络层次高的交换设备其优先级不一定高可以通过执行命令配置其为根桥。stp root命令用来配置当前交换设备为指定生成树的根桥或备份根桥。执行stp root primary命令指定当前交换设备为根桥则表示该设备在指定生成树中的优先级为0且优先级不能修改。[S2] stp root secondary执行stp root secondary命令指定当前交换设备在指定生成树中为备份根桥则表示该设备的优先级数值为4096且优先级不能修改。# 在S1上查看当前STP状态[S1] display stpCIST Global Information:Mode :STPCIST Bridge :0.20df-73f5-44e1Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20CIST Root/ERPC :0.20df-73f5-44e1 / 0 (This bridge is the root)CIST RegRoot/IRPC :0.20df-73f5-44e1 / 0 (This bridge is the root)CIST RootPortId :0.0BPDU-Protection :DisabledCIST Root Type :Primary rootTC or TCN received :94TC count per hello :0STP Converge Mode :NormalShare region-configuration :EnabledTime since last TC :0 days 0h:0m:1sNumber of TC :23Last TC occurred :GE1/0/11Topo Change Flag :0此时自身桥ID与根桥ID相同且根路径开销为0说明S1是当前网络的根桥。# 在所有设备上查看STP状态摘要[S1] display stp briefMSTID Port Role STP State Protection Cost Edged0 GE1/0/11 DESI forwarding none 20000 disable0 GE1/0/12 DESI forwarding none 20000 disable0 GE1/0/13 DESI forwarding none 20000 disable0 GE1/0/14 DESI forwarding none 20000 disable[S2] display stp briefMSTID Port Role STP State Protection Cost Edged0 GE1/0/11 ROOT forwarding none 20000 disable0 GE1/0/12 ALTE discarding none 20000 disable0 GE1/0/13 DESI forwarding none 20000 disable0 GE1/0/14 DESI forwarding none 20000 disable[S3] display stp briefMSTID Port Role STP State Protection Cost Edged0 GE1/0/1 ROOT forwarding none 20000 disable0 GE1/0/2 ALTE discarding none 20000 disable0 GE1/0/3 ALTE discarding none 20000 disable[S4] display stp briefMSTID Port Role STP State Protection Cost Edged0 GE1/0/1 ROOT forwarding none 20000 disable0 GE1/0/2 ALTE discarding none 20000 disable0 GE1/0/3 DESI forwarding none 20000 disable# 综合根桥ID信息以及各个交换机上的端口信息可得当前拓扑如下步骤 4修改设备参数使得S4的GE1/0/2接口成为根端口# 查看S4上的STP状态信息[S4] display stpCIST Global Information:Mode :STPCIST Bridge :32768.20df-73f5-4331Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20CIST Root/ERPC :0.20df-73f5-44e1 / 20000CIST RegRoot/IRPC :32768.20df-73f5-4331 / 0 (This bridge is the root)CIST RootPortId :128.1 (GE1/0/1)BPDU-Protection :DisabledTC or TCN received :96TC count per hello :0STP Converge Mode :NormalShare region-configuration :EnabledTime since last TC :0 days 0h:6m:49sNumber of TC :18Last TC occurred :GE1/0/1Topo Change Flag :0当前S4到S1的根路径开销为20000。# 修改S4的GE 1/0/1的STP开销值为50000[S4] interface GE 1/0/1[S4-GE1/0/1] stp cost 50000[S4-GE1/0/1] quit# 查看当前STP状态信息摘要[S4] display stp briefMSTID Port Role STP State Protection Cost Edged0 GE1/0/1 ALTE discarding none 50000 disable0 GE1/0/2 ROOT forwarding none 20000 disable0 GE1/0/3 ALTE discarding none 20000 disableS4的GE1/0/2接口已经成为根端口。# 查看当前STP状态信息[S4] display stpCIST Global Information:Mode :STPCIST Bridge :32768.20df-73f5-4331Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20CIST Root/ERPC :0.20df-73f5-44e1 / 40000 //S4到根桥的Cost值为40000CIST RegRoot/IRPC :32768.20df-73f5-4331 / 0 (This bridge is the root)CIST RootPortId :128.2 (GE1/0/2)BPDU-Protection :DisabledTC or TCN received :178TC count per hello :8STP Converge Mode :NormalShare region-configuration :EnabledTime since last TC :0 days 0h:0m:5sNumber of TC :22Last TC occurred :GE1/0/2Topo Change Flag :0当前拓扑如下步骤 5修改当前生成树工作模式为RSTP# 修改所有设备的生成树模式[S1] stp mode rstp[S2] stp mode rstp[S3] stp mode rstp[S4] stp mode rstp# 查看设备上的生成树状态仅以S1为例[S1] display stpCIST Global Information:Mode :RSTPCIST Bridge :0.20df-73f5-44e1Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20CIST Root/ERPC :0.20df-73f5-44e1 / 0 (This bridge is the root)CIST RegRoot/IRPC :0.20df-73f5-44e1 / 0 (This bridge is the root)CIST RootPortId :0.0BPDU-Protection :DisabledCIST Root Type :Primary rootTC or TCN received :97TC count per hello :0STP Converge Mode :NormalShare region-configuration :EnabledTime since last TC :0 days 0h:5m:29sNumber of TC :26Last TC occurred :GE1/0/11Topo Change Flag :0模式修改后对生成树的整体拓扑无影响。步骤 6配置边缘端口# S3的GE 1/0/10-1/0/24确认只会连接终端设备需要被配置为边缘端口[S3] interface range GE 1/0/10 to GE 1/0/24通常设备的以太网接口数比较多并且在很多以太网接口下有相同的配置。如果对这些以太网接口进行逐个配置会较为繁琐且容易输入错误。因此将需要执行相同配置命令的以太网接口加入到一个临时端口组在临时端口组配置命令时系统会自动到临时端口组绑定的所有成员接口下执行这些命令行完成以太网接口批量配置。注某些产品可能不支持临时接口组需要对接口做单独配置。[S3-port-group] stp edged-port enablestp edged-port enable命令用来配置当前端口为边缘端口。当前端口配置成边缘端口后如果收到BPDU报文交换设备会自动将边缘端口设置为非边缘端口并重新进行生成树计算。学习教程实验案例领取方式↓↓↓这里直接找我或评论区666告诉我

更多文章