1.STP定义
- STP是一个用于局域网中消除环路的协议,它的标准是IEEE 802.1D。
2.作用
- STP通过将部分冗余链路强制为阻塞状态,其他链路处于转发状态,将环形网络结构修剪成无环路的树形网络结构,可实现消除环路。当处于转发状态的链路不可用时,STP重新配置网络,并激活合适的备用链路状态,恢复恢复网络连通性。
3.实验基础搭建
- 配置环网中的设备生成树协议工作在 STP 模式
- 配置根桥和备份根桥设备
- 配置端口的路径开销值,实现将该端口阻塞
- 使能 STP,实现破除环路
4.STP协议配置
# SW1
[SW1]stp mode stp
# SW2
[SW2]stp mode stp
# SW3
[SW3]stp mode stp
# SW4
[SW4]stp mode stp
# SW1
[SW1]stp root primary
# SW2
[SW2]stp root secondary
# SW1
[SW1]stp pathcost-standard legacy
# SW2
[SW2]stp pathcost-standard legacy
# SW3
[SW3]stp pathcost-standard legacy
[SW3]interface GigabitEthernet 0/0/3
[SW3-GigabitEthernet0/0/3]stp cost 20000
# SW4
[SW4]stp pathcost-standard legacy
# SW3
[SW3]interface g0/0/24
[SW3-GigabitEthernet0/0/24]stp edged-port enable
[SW3-GigabitEthernet0/0/24]stp bpdu-filter enable
# SW4
[SW4]interface g0/0/24
[SW4-GigabitEthernet0/0/24]stp edged-port enable
[SW4-GigabitEthernet0/0/24]stp bpdu-filter enable
# SW1
[SW1]stp enable
# SW2
[SW2]stp enable
# SW3
[SW3]stp enable
# SW4
[SW4]stp enable
5.实验验证
- 在 Switch1 和 Switch2 上执行 display stp brief 命令
查看端口状态和端口的保护类型
- 在 Switch3上执行 display stp interface gigabitethernet 0/0/3 brief 命令
查看端口 GigabitEthernet0/0/3 状态
- 在 Switch4上执行 display stp brief 命令
查看端口状态