文章核心: 1.STP协议是什么? 2.STP选举规则 3.STP简单实验 4.STP基本配置python
(1)为何要用STP协议? 为了解决第二层网络环路问题而又要保证网络的稳定和健壮性,引入了链路动态管理的策略。首先经过阻塞某些链路避免环路的产生(避免环路),当正常工做的链路因为故障断开时,阻塞的链路马上激活,迅速取代故障链路的位置,保证网络的正常运行。(生成冗余链路)这就是生成树(STP)协议。 (2)解决环路问题 避免环路 每一个LAN都会选择一台设备为指定交换机,经过该设备的端口链接到根,该端口为指定端口( Designated port ) 将交换网络中全部设备的根端口(RP)和指定端口(DP)设为转发状态(Forwarding),将其余端口设为阻塞状态(Blocking) 生成树通过一段时间(默认值是50秒左右)稳定以后,全部端口要么进入转发状态,要么进入阻塞状态。 (3)创建冗余链路让网络更稳定 冗余链路能够理解为备份链路,其余链路出现问题了备份的冗余链路会代替上去,维持网络稳定markdown
说白了就是我在一个阶段给你发请求你长时间不回应,我会结束这个阶段进入下一个阶段 当网络的拓扑发生变化时,网络会从一个状态向另外一个状态过渡,从新打开或阻断某些端口。交换机的端口要通过几种状态:禁用(Disable)——>阻塞(Blocking)——>监听状态(Listenning)——>学习状态(Learning)——>转发状态(Forwarding) 4、STP中根桥,根端口,指定端口的选举规则: 1.在一个广播域选择一个根桥 使用stp协议,会向邻居s发送BPDU,bridge protocol date unit 交换机向所在广播域发送的bpdu 内容有: bridge ID 优先级 mac地址 选举规则: 主板mac地址,交换机端口mac地址是端口号+主板mac地址得来 查看优先级,mac地址,网桥ID依次查看选取最小的为根桥 2.每一个非根桥选择一个根端口(RP) 1.路径成本最低 2.直连的网桥id最小 3.最低发送者端口id最小 3.每一个段选择一个指定端口(DP) 每个线链接的两段选一个指定端口,RP的对端确定是DP 对比bri id优先成为dp,另外一个无身份 4.阻塞非指定端口 没有身份的会被阻塞掉,称为AP,用来防环 指定端口发bpdu,根端口接受 5.个端口状态 block 非指定端口回到block状态 listen 监听bpdu,不能学习mac地址,不转发数据,维持15秒,肯定端口角色! learn 学习mac地址,不转发数据,维持15秒 forword 可转发数据 disable 禁用网络
1.理解STP中端口角色变化规则 2.掌握基本配置STP协议学习
1、在Cisco模拟器中拖三台交换机链接查看他们的默认生成树状况 咱们在图中也能够看出S0为根桥两个端口分别是指定端口 S1两个端口与S0对应的端口为根端口,另外一个为指定端口 S2两个端口与S0对应的为根端口,另外一个为非指定端口(阻塞端口) 黄色的等表明就是阻塞端口(非指定端口)ui
S0
Switch#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
# 根桥的信息
Root ID Priority 32769 # 根桥的优先级
Address 0001.63D0.3450 # 根桥的mac地址
This bridge is the root # 这个s是根桥
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 0001.63D0.3450
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Desg FWD 19 128.1 P2p # 能够看出与根桥两个端口都是指定端口
Fa0/2 Desg FWD 19 128.2 P2p # 指定端口
S1
Switch#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 0001.63D0.3450
Cost 19
Port 1(FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 0090.216C.B791
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2 Desg FWD 19 128.2 P2p # 指定端口,妆发状态
Fa0/1 Root FWD 19 128.1 P2p # 根端口(与),转发状态
S2
Switch#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 0001.63D0.3450
Cost 19
Port 1(FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 00E0.A3D9.8D5E
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Root FWD 19 128.1 P2p #根端口,处于转发状态
Fa0/2 Altn BLK 19 128.2 P2p #阻塞端口,处于block状态
复制代码
从图中能够看出变化S1成了根桥,S0为备份根桥。若是S1出故障了S0会代替S1称为根桥 再次查看Switch生成树状态spa
S0
Switch(config)#spanning-tree vlan 1 root secondary
Switch#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 24577
Address 0090.216C.B791
Cost 19
Port 1(FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 28673 (priority 28672 sys-id-ext 1)
Address 0001.63D0.3450
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Root FWD 19 128.1 P2p
Fa0/2 Desg FWD 19 128.2 P2p
S1
Switch(config)#spanning-tree vlan 1 root primary
Switch#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 24577
Address 0090.216C.B791
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 24577 (priority 24576 sys-id-ext 1)
Address 0090.216C.B791
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2 Desg FWD 19 128.2 P2p
Fa0/1 Desg FWD 19 128.1 P2p
S2
Switch#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 24577
Address 0090.216C.B791
Cost 19
Port 2(FastEthernet0/2)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 00E0.A3D9.8D5E
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Altn BLK 19 128.1 P2p
Fa0/2 Root FWD 19 128.2 P2p
复制代码