【华为网络-配置-021】- MSTP 多实例配置及安全保护等

要求:

1、vlan 10 从红色链路转发。
2、vlan 20 从黄色链路转发。

一、基础配置

b 复制代码
[SW1]vlan batch 10 20
[SW1]interface GigabitEthernet 0/0/1
[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW1-GigabitEthernet0/0/1]quit
[SW1]interface GigabitEthernet 0/0/2
[SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[SW1-GigabitEthernet0/0/2]quit

[SW2]vlan batch 10 20
[SW2]interface GigabitEthernet 0/0/1
[SW2-GigabitEthernet0/0/1]port link-type trunk
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW2-GigabitEthernet0/0/1]quit
[SW2]interface GigabitEthernet 0/0/2
[SW2-GigabitEthernet0/0/2]port trunk allow-pass vlan all

[SW3]vlan batch 10 20
[SW3]interface GigabitEthernet 0/0/1
[SW3-GigabitEthernet0/0/1]port link-type trunk
[SW3-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW3-GigabitEthernet0/0/1]quit
[SW3]interface GigabitEthernet 0/0/2
[SW3-GigabitEthernet0/0/2]port trunk allow-pass vlan all

二、多实例配置

b 复制代码
开启 STP 服务。设置 STP 服务为 MSTP。
[SW1]stp enable
[SW1]stp mode mstp

进入 STP 配置视图。
[SW1]stp region-configuration

创建名为 msgroup01 的组名称(名称可自定义,但需要保证所有加入的节点名称一致)。
[SW1-mst-region]region-name msgroup01

创建实例 1 并允许通过的 vlan 号为 10 至 19 。
[SW1-mst-region]instance 1 vlan 10 to 19

创建实例 2 并允许通过的 vlan 号为20 至 29。
[SW1-mst-region]instance 2 vlan 20 to 29

激活 STP 配置。
[SW1-mst-region]active region-configuration 

在其他加入的节点中,使用一模一样的配置(跟 SW1 一样)。
[SW2]stp enable
[SW2]stp mode mstp
[SW2]stp region-configuration
[SW2-mst-region]region-name msgroup01
[SW2-mst-region]instance 1 vlan 10 to 19
[SW2-mst-region]instance 2 vlan 20 to 29
[SW2-mst-region]active region-configuration 

[SW3]stp enable
[SW3]stp mode mstp
[SW3]stp region-configuration
[SW3-mst-region]region-name msgroup01
[SW3-mst-region]instance 1 vlan 10 to 19
[SW3-mst-region]instance 2 vlan 20 to 29
[SW3-mst-region]active region-configuration

设置实例优先级。
配置 SW2 的实例 1 优先级高(实例 1 包含 vlan 10)。
(4096 是因为原交换机默认优先级是 32768 ,实际项目中需要先看默认优先级,再调整这里的优先级大小)。
[SW2]stp instance 1 priority 4096
[SW2]stp instance 2 priority 8192

配置 SW3 的实例 2 优先级高(实例 2 包含 vlan 20)。
[SW3]stp instance 1 priority 8192
[SW3]stp instance 2 priority 4096

三、扩展配置

3.1 配置接口为边缘端口

b 复制代码
一般用于连接终端的交换机接口,可以避免终端因频繁上下线导致的网络震荡。

全局配置(配置当前设备上所有端口为边缘端口,一般不这样设置)
[SW1]stp edged-port default

接口配置(开启)(也可以更改 enable 参数,使用 disable 关闭此边缘端口)
[SW1]interface GigabitEthernet 0/0/1
[SW1-GigabitEthernet0/0/1]stp edged-port enable

3.2 开启 BPDU 保护

b 复制代码
防止环路和避免协议攻击(配合边缘端口使用)。(如果在某个接口收到自己发出的 BPDU 报文,那就将此接口关闭)。
[SW1]stp bpdu-protection

设置因为 BPDU 保护关闭的接口重新恢复的间隔时间(秒)(60 可更改)。
[SW1]error-down auto-recovery cause bpdu-protection interval 60

3.3 根保护(DP接口下设置)

b 复制代码
避免由于错误配置或恶意攻击导致的 STP 根桥地位丢失(跟环路保护功能冲突)。
[SW2]interface GigabitEthernet 0/0/1
[SW2-GigabitEthernet0/0/1]stp root-protection

3.4 配置泛洪保护(全局,默认是 1 )

b 复制代码
一段时间内,处理 BPDU 的数量。
[SW1]stp tc-protection threshold 5

3.5 关闭接受 BPDU 报文(接口收到后丢弃,但不影响发送)

b 复制代码
[SW1]interface GigabitEthernet 0/01
[SW1-GigabitEthernet0/0/1]bpdu disable

3.6 接口关闭 STP(接口不发送 BPDU 报文)

b 复制代码
[SW1]interface GigabitEthernet 0/01
[SW1-GigabitEthernet0/0/1]stp disable

3.7 接口关闭 STP 透传 BPDU 报文

b 复制代码
CE交换机
[SW1]interface GigabitEthernet 0/01
[SW1-GigabitEthernet0/0/1]bpdu bridge enable

S系列交换机
[SW1]interface GigabitEthernet 0/01
[SW1-GigabitEthernet0/0/1]stp disable
[SW1-GigabitEthernet0/0/1]l2protocol-tunnel stp enable
相关推荐
Sylvia33.15 分钟前
LOL实时数据接入深度解析:从WebSocket到完整数据模型
java·网络·python·websocket·网络协议
鼹鼠SDN3 小时前
没有公网 IP,如何在外面访问家里的打印机、摄像头和整个局域网?
网络·网络协议·tcp/ip
旭华智能sunvua5 小时前
城市智慧排水安全监测综合解决方案
安全
小诗懂技术6 小时前
【网络通信UDP】基础 进程间不同主机的通信
运维·服务器·网络
名字还没想好☜6 小时前
Docker 容器安全加固实战:非 root、只读根文件系统、drop capabilities 与最小攻击面
运维·安全·docker·容器·kubernetes
Hstar_chen6 小时前
开源一款 HarmonyOS 服务器监控客户端:星辰云巡 1.0.3
服务器·华为·harmonyos
华普微HOPERF7 小时前
数字隔离器,光伏微型逆变系统中的安全核“芯”
安全
DM今天肝到几点?8 小时前
AI 安全进入「攻防同频」:Gemini 3.8 Flash Cyber 上线、Astra 触及关键级、HiddenLayer 融资 1 亿美元
网络·人工智能·深度学习·安全·语言模型·开源·知识图谱
幼儿园蛋小黑8 小时前
TCP 并发:从原理到高并发实践
网络·网络协议·tcp/ip
来让爷抱一个9 小时前
2026 智能体安全实战:把护栏写进SPEC,MonkeyCode 云端跑通
人工智能·安全·机器学习