STP
-定义
-作用
-类型
1、802.1d – STP :生成树协议 PVST/PVST+(思科)
2、802.1w – RSTP :快速生成树协议 PV-RSTP(思科)
3、802.1s – MSTP :多生成树协议
-报文PVST:per-vlan STP,即在每个 VLAN 内部都运行一个 STP (802.1d);STP的工作过程:
1、确定交换机的角色
根交换机:整个交换网络中,有且只有一个;
非根交换机:剩余的其他交换机,都称之为非根交换机BPDU类型:
1、配置BPDU
用于创建和维护 STP 无环转发路径树
2、TCN BPDU
只有当 STP 无环转发路径树(拓扑)变化的时候,才会
产生并发送。
并且是:感知到该变化的交换机,产生 TCN BPDU ,只
发送给根交换机,然后再由根交换机转发给其他的所有
非根交换机;STP计时器:
hello:交换机周期性发送 BPDU 的时间间隔,默认是 2s ;
forward-delay : 转发延迟,默认时间为15s ;
max-age:最大老化时间,默认时间为 20s ;STP参数修改(思科):
1、修改交换机的 STP 优先级 (确保网络中有主根交换机和辅根交换机)
spanning-tree vlan x priority {value} , value 是4096的倍数STP参数修改(华为):
1、修改交换机的 STP 优先级:
[SW] stp priority {value} -> 必须得是4096的倍数
2、修改交换机的 STP 模式
[SW] stp mode {stp | rstp | mstp }
3、修改交换机的端口的 STP cost :
[SW]interface fas0/13
[sw-fas0/13]stp cost {value}
4、在交换机上关闭/开启 STP :
[sw]stp disable -> 关闭 STP ;
[sw]stp enable -> 开启 STP ,默认是开启的;验证命令:
show spanning-tree vlan x ->可以查看交换机上关于 VLAN x 的 STP 信息
show spanning-tree ->可以查看交换机上关于所有VLAN的 STP 信息
show spanning-tree summary ->可以查看交换机运行的 STP 的模式;
show version -> 可以查看交换机的 base mac ;注意:
交换机上的 STP 功能,默认都是开启的;可以人工关闭;=============================================================
MSTP的配置:MSTI(instance),即MST 实例,一个MSTI 可以同时关联多个 VLAN ;配置 MST region
[SW]stp region-configuration
[sw-mstp-region]region-name {string} //配置 region 的名字;
[sw-mstp-region]instance {id} vlan x y z m n //配置关联的VLAN
[sw-mstp-region]active region-configuration
[sw-mstp-region]display this
配置 MSTI
[sw1]stp instance {id} priority {value}
验证命令:
display stp instance {id}
display stp brief
注意:
默认情况下,所有的 VLAN 都是属于 instance 0 ; (系统的默认instance)
一个MSTP网络中,可以同时包含多个 region ;
每个MST Region 中,可以包含多个 instance (MSTI)
属于相同 region 的交换机上,以下参数必须相同:
#region-name
#实例与vlan的映射关系必须相同属于同一个 region 中的多个交换机之间,可以基于 instance 进行
流量的负载均衡和备份;=====================================================================STP 收敛速度比较慢 :30-50s RSTP收敛速度要比 STP 快,因为做了以下改进:
1、发现问题比较快2、反应/传输问题比较快
发现拓扑变更的交换机,会产生TCN BPDU,直接发送给与自己相连
的其他所有交换机;端口角色细化:(边缘端口:一般都建议关闭 STP ;或者将连接非交换机的端口,设置非边缘端口)端口状态精简化:
learning :学习
forwarding :转发
discarding :丢弃,相当于之前 STP 中的 down / blocking / listening案例:1 案例1:STP算法
1.1 问题
选择出根网桥、根端口、指定端口、被阻塞的端口。1.2 方案
如图-1所示:1.3 步骤
实现此案例需要按照如下步骤进行。1)每个广播域选择根网桥(Root Bridge)每个非根网桥选择根端口(Root Ports)
每个网段上选择指定端口(Designated Ports)
2)结果如图-2所示2 案例2:配置STP
2.1 问题
首先查看当前根网桥,然后通过修改交换机的优先级来分配根网桥。2.2 方案
使用eNSP搭建实验环境,如图-3所示。2.3 步骤
实现此案例需要按照如下步骤进行。[A]stp mode stp
[B]stp mode stp
[C]stp mode stp
[D]stp mode stp
[A]dis stp
——-[CIST Global Info][Mode STP]——-
CIST Bridge :32768.4c1f-cc3b-03cb
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :32768.4c1f-cc17-3481 / 200000
CIST RegRoot/IRPC :32768.4c1f-cc3b-03cb / 0
CIST RootPortId :128.2
BPDU-Protection :Disabled
TC or TCN received :106
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:9m:8s
Number of TC :12
Last TC occurred :Ethernet0/0/2
[B]dis stp
——-[CIST Global Info][Mode STP]——-
CIST Bridge :32768.4c1f-cc17-3481
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :32768.4c1f-cc17-3481 / 0
CIST RegRoot/IRPC :32768.4c1f-cc17-3481 / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
TC or TCN received :23
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:9m:52s
Number of TC :13
Last TC occurred :Ethernet0/0/4
[C]dis stp
——-[CIST Global Info][Mode STP]——-
CIST Bridge :32768.4c1f-cc50-3d65
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :32768.4c1f-cc17-3481 / 400000
CIST RegRoot/IRPC :32768.4c1f-cc50-3d65 / 0
CIST RootPortId :128.4
BPDU-Protection :Disabled
TC or TCN received :92
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:10m:26s
Number of TC :11
Last TC occurred :Ethernet0/0/4
[D]dis stp
——-[CIST Global Info][Mode STP]——-
CIST Bridge :32768.4c1f-cc22-4507
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :32768.4c1f-cc17-3481 / 200000
CIST RegRoot/IRPC :32768.4c1f-cc22-4507 / 0
CIST RootPortId :128.2
BPDU-Protection :Disabled
TC or TCN received :49
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:11m:12s
Number of TC :13
Last TC occurred :Ethernet0/0/2
可以看出,交换机B是根网桥。[A]stp priority 4096
[A]dis stp
——-[CIST Global Info][Mode STP]——-
CIST Bridge :4096 .4c1f-cc3b-03cb
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc3b-03cb / 0
CIST RegRoot/IRPC :4096 .4c1f-cc3b-03cb / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
TC or TCN received :108
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:0m:14s
Number of TC :15
Last TC occurred :Ethernet0/0/3
此时,根网桥已经是交换机A了。3 案例3:配置MSTP及负载均衡
3.1 问题
配置MSTP实现多生成树效果
配置A成为vlan 10 和 20 的主根,vlan 30 和 40 的次根
配置B成为vlan 30 和 40 的主根,vlan 10 和 20 的次根
查看配置信息
3.2 方案
使用eNSP搭建实验环境,如图-4所示。3.3 步骤
实现此案例需要按照如下步骤进行。[A]vlan batch 10 20 30 40
[A]int e0/0/2
[A-Ethernet0/0/2]port link-type trunk
[A-Ethernet0/0/2]port trunk allow-pass vlan all
[A]int e0/0/3
[A-Ethernet0/0/3]port link-type trunk
[A-Ethernet0/0/3]port trunk allow-pass vlan all
交换机B、C也同样配置。[A]stp region-configuration
[A-mst-region]region-name tedu
[A-mst-region]instance 1 vlan 10 20
[A-mst-region]instance 2 vlan 30 40
[A-mst-region]active region-configuration
查看配置:[A-mst-region]dis this
#
stp region-configuration
region-name tedu
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration
#
return
交换机B、C也同样配置。3)配置主根与次根[A]stp instance 1 priority 4096
[A]stp instance 2 priority 8192
[B]stp instance 2 priority 4096
[B]stp instance 1 priority 8192
4)验证[A]dis stp instance 1
——-[MSTI 1 Global Info]——-
MSTI Bridge ID :4096.4c1f-cc87-1de7
MSTI RegRoot/IRPC :4096.4c1f-cc87-1de7 / 0
MSTI RootPortId :0.0
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :200000
TC received :5
TC count per hello :0
Time since last TC :0 days 0h:3m:6s
Number of TC :4
Last TC occurred :Ethernet0/0/2
—-[Port2(Ethernet0/0/2)][FORWARDING]—-
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc87-1de7 / 128.2
Port Times :RemHops 20
TC or TCN send :4
TC or TCN received :3
—-[Port3(Ethernet0/0/3)][FORWARDING]—-
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc87-1de7 / 128.3
Port Times :RemHops 20
TC or TCN send :2
TC or TCN received :2
[A]dis stp instance 2
——-[MSTI 2 Global Info]——-
MSTI Bridge ID :8192.4c1f-cc87-1de7
MSTI RegRoot/IRPC :4096.4c1f-cc0d-76bc / 200000
MSTI RootPortId :128.2
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :200000
TC received :4
TC count per hello :0
Time since last TC :0 days 0h:3m:49s
Number of TC :4
Last TC occurred :Ethernet0/0/2
—-[Port2(Ethernet0/0/2)][FORWARDING]—-
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc0d-76bc / 128.1
Port Times :RemHops 20
TC or TCN send :4
TC or TCN received :3
—-[Port3(Ethernet0/0/3)][FORWARDING]—-
Port Role :Designated Port
Port Priority :128
Po开发云主机域名rt Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :8192.4c1f-cc87-1de7 / 128.3
Port Times :RemHops 19
TC or TCN send :2
TC or TCN received :1
[B]dis stp instance 1
——-[MSTI 1 Global Info]——-
MSTI Bridge ID :8192.4c1f-cc0d-76bc
MSTI RegRoot/IRPC :4096.4c1f-cc87-1de7 / 200000
MSTI RootPortId :128.1
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :0
TC received :4
TC count per hello :0
Time since last TC :0 days 0h:5m:26s
Number of TC :4
Last TC occurred :Ethernet0/0/3
—-[Port1(Ethernet0/0/1)][FORWARDING]—-
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc87-1de7 / 128.2
Port Times :RemHops 20
TC or TCN send :3
TC or TCN received :4
—-[Port3(Ethernet0/0/3)][FORWARDING]—-
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :8192.4c1f-cc0d-76bc / 128.3
Port Times :RemHops 19
TC or TCN send :1
TC or TCN received :0
[B]dis stp instance 2
——-[MSTI 2 Global Info]——-
MSTI Bridge ID :4096.4c1f-cc0d-76bc
MSTI RegRoot/IRPC :4096.4c1f-cc0d-76bc / 0
MSTI RootPortId :0.0
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :0
TC received :6
TC count per hello :0
Time since last TC :0 days 0h:6m:4s
Number of TC :5
Last TC occurred :Ethernet0/0/3
—-[Port1(Ethernet0/0/1)][FORWARDING]—-
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc0d-76bc / 128.1
Port Times :RemHops 20
TC or TCN send :3
TC or TCN received :4
—-[Port3(Ethernet0/0/3)][FORWARDING]—-
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc0d-76bc / 128.3
Port Times :RemHops 20
TC or TCN send :2
TC or TCN received :2
[C]dis stp instance 1
——-[MSTI 1 Global Info]——-
MSTI Bridge ID :32768.4c1f-ccb8-32b8
MSTI RegRoot/IRPC :4096.4c1f-cc87-1de7 / 200000
MSTI RootPortId :128.1
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :200000
TC received :3
TC count per hello :0
Time since last TC :0 days 0h:6m:58s
Number of TC :3
Last TC occurred :Ethernet0/0/1
—-[Port1(Ethernet0/0/1)][FORWARDING]—-
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc87-1de7 / 128.3
Port Times :RemHops 20
TC or TCN send :2
TC or TCN received :2
—-[Port2(Ethernet0/0/2)][DISCARDING]—-
Port Role :Alternate Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :8192.4c1f-cc0d-76bc / 128.3
Port Times :RemHops 19
TC or TCN send :0
TC or TCN received :1
[C]dis stp instance 2
——-[MSTI 2 Global Info]——-
MSTI Bridge ID :32768.4c1f-ccb8-32b8
MSTI RegRoot/IRPC :4096.4c1f-cc0d-76bc / 200000
MSTI RootPortId :128.2
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :200000
TC received :4
TC count per hello :0
Time since last TC :0 days 0h:7m:32s
Number of TC :4
Last TC occurred :Ethernet0/0/2
—-[Port1(Ethernet0/0/1)][DISCARDING]—-
Port Role :Alternate Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :8192.4c1f-cc87-1de7 / 128.3
Port Times :RemHops 19
TC or TCN send :1
TC or TCN received :2
—-[Port2(Ethernet0/0/2)][FORWARDING]—-
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc0d-76bc / 128.3
Port Times :RemHops 20
TC or TCN send :2
TC or TCN received :2
查看负载均衡:[A]dis stp bri
MSTID Port Role STP State Protection
0 Ethernet0/0/2 ROOT FORWARDING NONE
0 Ethernet0/0/3 DESI FORWARDING NONE
1 Ethernet0/0/2 DESI FORWARDING NONE
1 Ethernet0/0/3 DESI FORWARDING NONE
2 Ethernet0/0/2 ROOT FORWARDING NONE
2 Ethernet0/0/3 DESI FORWARDING NONE
[B]dis stp bri
MSTID Port Role STP State Protection
0 Ethernet0/0/1 DESI FORWARDING NONE
0 Ethernet0/0/3 DESI FORWARDING NONE
1 Ethernet0/0/1 ROOT FORWARDING NONE
1 Ethernet0/0/3 DESI FORWARDING NONE
2 Ethernet0/0/1 DESI FORWARDING NONE
2 Ethernet0/0/3 DESI FORWARDING NONE
[C]dis stp bri
MSTID Port Role STP State Protection
0 Ethernet0/0/1 ALTE DISCARDING NONE
0 Ethernet0/0/2 ROOT FORWARDING NONE
1 Ethernet0/0/1 ROOT FORWARDING NONE
1 Ethernet0/0/2 ALTE DISCARDING NONE
2 Ethernet0/0/1 ALTE DISCARDING NONE
2 Ethernet0/0/2 ROOT FORWARDING NONE
C上VLAN 10 20的流量通过Ethernet0/0/1口到A,VLAN 30 40的流量通过Ethernet0/0/2口到B,实现了链路的负载均衡。
相关推荐: Win10首次启动出现计算机意外地重启或遇到错误的解决方法
Win10系统安装完后首次开机时系统弹出窗口,提示:计算机意外重新启动或遇到错误,导致系统安装无法继续。这是怎么回事,下面让小编来讲解这个问题的解决方法吧。 故障分析: 首次启动Win10系统时提示:计算机意外地重新启动或遇到错误。Windows开发云主机…
免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。