STP 二 - 关于生成树的思科命令
想到了就总结一下,以后用起来也方便查询
Bridge ID包括:
1. Bridge Priority (0-61440 以4096递增)
2. System ID Extension (0-4095 实际就是vlan id)
3. MAC地址
改变根桥选举过程
1. 手动更改BID 优先级 - 数字越小越好
Router(config)#spanning-tree vlan 1 priority ?
<0-65535> bridge priority
2. 直接指定根桥 (基于当前root更改本地优先级)
Router(config)#spanning-tree vlan 1 root ?
primary Configure this switch as primary root for this spanning tree
secondary Configure switch as secondary root
3. 验证
- sh spanning-tree vlan [vlan ID]
- Router#sh spanning-tree root
VLAN1
Root ID Priority 32768
Address cc00.5f24.0000
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
根端口选举 (RP election)
- RP是上行面向根桥的端口
- 根据最小的链路代价来选举的(lowest Root Path Cost)
- 链路代价(带宽越大,代价约小 且不是线性的)
- 如果链路代价一样:更低的上行交换机BID,更小的上行端口号
DP选举
DP 是下行远离根桥的端口,选择方法和根端口一样
- 最小链路代价
- 最小BID
- 最小端口号
剩余非根端口,非DP,则进入block mode (根本上讲该端口不会录入MAC地址到CAM table)
- 接收BPDU包
- 忽略所有其他数据包
- 不能发送数据包
更改端口代价
-Router(config-if)#spanning-tree vlan 1 cost ?
<1-65535> Change an interface's per VLAN spanning tree path cost
- bandwidth [bps]
验证
- sh spanning -tree interface [int ID] detail
- sh spanning-tree vlan [vlan ID] detail
=========
命令输出读取root path cost
1. sh spanning-tree vlan [vlan ID] brief (似乎有的版本不需要输入brief, 如下图,31是端到端的root path cost)