STP 生成树协议--从逻辑上断开环路,防止广播风暴的产生
** 将一个环形网络生成无环拓扑的步骤
- 选择根网桥 (Root Bridge)
- 选择根端口 (Root Ports)
- 选择指定端口 (Designated Ports)
网桥ID (BID)<小优先>=网桥优先级+MAC地址 (优先级默认值32768 取值0-65535)
** 根端口选择依据 RP
- 根路径成本最低
- 直连网桥ID最小
- 直连网桥端口ID最小 (对端设备端口序号小的优先)
** 链路带宽的高低规定 (链路:设备之间的网络路径)
10M-->100 100M-->19 1000M-->4 10000M-->2
** 端口ID =端口优先级+端口编号 (优先级默认128 取值0-255)
** 基本指令
sw# sh spanning-tree vlan 1 查看基本STP信息
eg:
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- --------
Fa0/1 Altn (阻塞/备用端口) BLK(阻塞)
19 128.1 P2p
Fa0/2 Root (根端口) FWD(通讯)
19 128.2 P2p
eg:
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Desg(指定端口) FWD 19 128.1 P2p
Fa0/2 Desg FWD 19 128.2 P2p
** 修改默认根桥
sw(config)#spanning-tree vlan 1 priority 值(必须是4096的倍数)
sw(config)#spanning-tree vlan 1 root primary (指定为根桥)
sw(config)#spanning-tree vlan 1 root secondary (指定为备份根桥)
** 修改端口优先级
sw(config-if)#spanning-tree vlan 1 port-priority 值 (取值16的倍数)
** 速端口优化 (仅限用于PC等非交换机设备,否则会引起广播风暴)
eg: pc1连接与sw1的f0/3接口
Sw1(config)#inte f0/3
Sw1(config-if)#spanning-tree portfast ---开启速端口模式,仅对当前端口有效