生成树协议STP!

一、STP协议

含义:STP(Spanning Tree Protocol,生成树协议)就是把交换机之间一个环路的结构改变成树形结构,它不是断掉物理连接,而是在逻辑上断开环路,防止广播风暴的产生,STP需要网络设备相互交换BPDU(网桥协议数据单元)来检测环路问题。
BPDU:
在这里插入图片描述

1.1生成树协议的功能

1)消除环路:通过阻塞冗余链路,从逻辑上断开环路,防止广播风暴的产生
环路能引起的问题:冗余链路会交给交换网络带来环路风险,并导致广播风暴以及MAC地址表不稳定等问题
2)链路备份:当活动的链路发生故障时,激活冗余链路,使网络通信正常进行

1.2生成树算法步骤

1)选择根网桥
先比较优先级,选最小,当优先级相等的情况下,选MAC地址小的
根ID=网桥优先级+网桥的MAC地址
根ID优先级的取值范围:0-65535(默认值:32768 )
2)每个非根网桥选择根端口(RP)
①选择到根桥最低的根路径成本,
②对比根桥ID最小
③对比端口ID最小的
端口ID=端口优先级+端口编号
端口优先级:0-255 默认值:128
3)选择指定端口(DP)
根网桥上的所有端口都是指定端口
①选择到根桥最低的根路径成本,
②对比根桥ID最小
③对比端口ID最小的
4)阻塞既不是根端口又不是指定端口的端口(AP)

1.3STP端口状态

在这里插入图片描述

二、MSTP配置实验

实验要求:交换机配置mstp,sw1为vlan10的主,vlan20的备,sw2为vlan20的主,vlan10的备,配置R1的loopback口为1.1.1.1,使得pc1和pc2可以ping通1.1.1.1
在这里插入图片描述
1)设置好PC1和PC2的IP地址,子网掩码,网关
2)分别在三台交换机里加入vlan,设置好各接口的工作模式,在三台交换机之间配置MSTP,sw1为vlan10的主,vlan20的备,sw2为vlan20的主,vlan10的备

3)设置R1的接口IP地址,以及loopback1的IP地址
SW1:

[SW1]v b 10 20                                        //创建vlan
[SW1-Ethernet0/0/1]port hybrid untagged vlan 10 20
[SW1-Ethernet0/0/1]int e0/0/2
[SW1-Ethernet0/0/2]port link-type trunk               //设置接口为trunk模式,放通所有vlan
[SW1-Ethernet0/0/2]port trunk allow-pass vlan all
[SW1-Ethernet0/0/2]int e0/0/3
[SW1-Ethernet0/0/3]port hybrid untagged vlan 10 20
[SW1-Ethernet0/0/3]
Apr 10 2021 10:25:39-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 10, the 
change loop count is 0, and the maximum number of records is 4095. User interface con0 is available
[SW1]stp region-configuration                        //进入MSTP域中
[SW1-mst-region]region-name whd
[SW1-mst-region]instance 1 vlan 10                   //将vlan加入实例中
[SW1-mst-region]instance 2 vlan 20
[SW1-mst-region]active region-configuration          //激活域
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW1]stp instance 1 root primary                     //设置实例1为主
[SW1]stp instance 2 root secondary  

SW2:

[SW2]v b 10 20
[SW2-Ethernet0/0/1]port hybrid untagged vlan 10 20
[SW2-Ethernet0/0/1]
Apr 10 2021 10:27:01-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 6, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW2-Ethernet0/0/1]int e0/0/2
[SW2-Ethernet0/0/2]port link-type trunk 
[SW2-Ethernet0/0/2]port trunk allow-pass  vlan all 
[SW2-Ethernet0/0/2]
Apr 10 2021 10:28:21-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 8, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW2-Ethernet0/0/2]int e0/0/3
[SW2-Ethernet0/0/3]port hybrid  untagged vlan 10 20
[SW2-Ethernet0/0/3]
Apr 10 2021 10:29:21-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 9, the c
hange loop count is 0, and the maximum number of records is 4095.
[SW2]stp region-configuration 
[SW2-mst-region]region-name whd
[SW2-mst-region]instance 1 vlan 10                           
[SW2-mst-region]instance 2 vlan 20
[SW2-mst-region]active region-configuration 
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW2]stp instance 1 root secondary
Apr 10 2021 10:41:21-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 11, the 
change loop count is 0, and the maximstp
[SW2]stp instance 2 root primary
Apr 10 2021 10:41:51-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 12, the 
change loop count is 0, and the maximum number of records is 4095.

SW3:

[SW3]v b 10 20
[SW3]int e0/0/1
[SW3-Ethernet0/0/1]port hybrid pvid vlan 10
[SW3-Ethernet0/0/1]port hybrid  untagged  vlan 10 20
[SW3-Ethernet0/0/1]int e0/0/2
[SW3-Ethernet0/0/2]port hybrid  pvid vlan 20
[SW3-Ethernet0/0/2]port hybrid  untagged vlan 10 20
[SW3-Ethernet0/0/2]int e0/0/3
[SW3-Ethernet0/0/3]port hybrid pvid vlan 20
[SW3-Ethernet0/0/3]port hybrid untagged vlan 10 20
[SW3-Ethernet0/0/3]int e0/0/4
[SW3-Ethernet0/0/4]port hybrid pvid vlan 10
[SW3-Ethernet0/0/4]port hybrid  untagged vlan 10 20
[SW3]stp region-configuration 
[SW3-mst-region]region-name whd
[SW3-mst-region]instance 1 vlan 10                           
[SW3-mst-region]instance 2 vlan 20
[SW3-mst-region]active region-configuration 

R1:

[R1-GigabitEthernet0/0/0]ip address 192.168.1.254 24
[R1-GigabitEthernet0/0/1]ip add 192.168.2.254 24
[R1]interface LoopBack 0
[R1-LoopBack0]ip a	
[R1-LoopBack0]ip address 1.1.1.1 24

实验结果:
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值