【华为交换】交换机MSTP+VRRP配置

功能简介

企业用户访问外网的流量,可能会同时包含二层流量和三层流量(例如,企业内二层VPN用户和三层VPN用户访问MPLS公网)。企业用户希望接入网络既能包含多条接入链路(不同链路之间互为备份)以保障接入的可靠性,又能实现二层流量和三层流量的负载分担,以实现对网络资源的充分利用。

这种情况,可以通过VRRP与MSTP配合部署解决。其中,针对三层流量,在网关部署VRRP;针对二层流量,采用冗余链路,并部署MSTP。这样,即可以提高二、三层接入的可靠性,又可以通过VRRP协议中Master设备与Backup设备的选择、MSTP协议中根桥与备份根桥的选择,实现二、三层流量的负载分担。

配置方法

复制代码
核心交换机1配置:
//建立VLAN
<HUAWEI>system-view immediately    //CE系列设备需要增加immediately进入实时生效模式
[HUAWEI]vlan batch 10 20 30 40 50 100
[HUAWEI]

//进入SVI接口配置地址
[HUAWEI]interface Vlanif 10
[HUAWEI-Vlanif10]ip address 192.168.10.252 24
[HUAWEI-Vlanif10]quit
[HUAWEI]interface Vlanif 20
[HUAWEI-Vlanif20]ip address 192.168.20.252 24
[HUAWEI-Vlanif20]quit
[HUAWEI]interface Vlanif 30
[HUAWEI-Vlanif30]ip address 192.168.30.252 24
[HUAWEI-Vlanif30]quit
[HUAWEI]interface Vlanif 40
[HUAWEI-Vlanif40]ip address 192.168.40.252 24
[HUAWEI-Vlanif40]quit
[HUAWEI]interface Vlanif 50
[HUAWEI-Vlanif50]ip address 192.168.50.252 24
[HUAWEI-Vlanif50]quit
[HUAWEI]interface Vlanif 100
[HUAWEI-Vlanif100]ip address 192.168.100.252 24
[HUAWEI-Vlanif100]quit
[HUAWEI]

//与其他交换机互联端口设置:
[HUAWEI]interface Eth-Trunk 1
[HUAWEI-Eth-Trunk1]mode lacp-static
[HUAWEI-Eth-Trunk1]trunkport GE 1/0/1 to 1/0/2
[HUAWEI-Eth-Trunk1]port link-type trunk
[HUAWEI-Eth-Trunk1]port trunk allow-pass vlan 10 20 30 40 50 100
[HUAWEI-Eth-Trunk1]quit
[HUAWEI]interface Eth-Trunk 2
[HUAWEI-Eth-Trunk2]mode lacp-static
[HUAWEI-Eth-Trunk2]trunkport GE 1/0/3 to 1/0/4
[HUAWEI-Eth-Trunk2]port link-type trunk
[HUAWEI-Eth-Trunk2]port trunk allow-pass vlan 10 20 30 40 50 100
[HUAWEI-Eth-Trunk2]quit
[HUAWEI]

//配置MSTP:
[HUAWEI]stp mode mstp
[HUAWEI]stp region-configuration
[HUAWEI-mst-region]instance 1 vlan 10 20 30
[HUAWEI-mst-region]instance 2 vlan 40 50 100
[HUAWEI-mst-region]revision-level 1
[HUAWEI-mst-region]region-name test
[HUAWEI-mst-region]active region-configuration        //部分型号没有此命令
[HUAWEI-mst-region]quit
[HUAWEI]

//配置MSTP优先级(方法1):
[HUAWEI]stp instance 1 priority 4096
[HUAWEI]stp instance 2 priority 8192
[HUAWEI]

//配置MSTP优先级(方法2):
[HUAWEI]stp instance 1 root primary
[HUAWEI]stp instance 2 root secondary
[HUAWEI]

//启动生成树协议:
[HUAWEI]stp enable
Warning: The global STP state will be changed. Continue? [Y/N]:Y
[HUAWEI]

//配置VRRP:
[HUAWEI]interface Vlanif 10
[HUAWEI-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
[HUAWEI-Vlanif10]vrrp vrid 10 priority 150
[HUAWEI-Vlanif10]quit
[HUAWEI]interface Vlanif 20
[HUAWEI-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.254
[HUAWEI-Vlanif20]vrrp vrid 20 priority 150
[HUAWEI-Vlanif20]quit
[HUAWEI]interface Vlanif 30
[HUAWEI-Vlanif30]vrrp vrid 30 virtual-ip 192.168.30.254
[HUAWEI-Vlanif30]vrrp vrid 30 priority 150
[HUAWEI-Vlanif30]quit
[HUAWEI]interface Vlanif 40
[HUAWEI-Vlanif40]vrrp vrid 40 virtual-ip 192.168.40.254
[HUAWEI-Vlanif40]vrrp vrid 40 priority 120
[HUAWEI-Vlanif40]quit
[HUAWEI]interface Vlanif 50
[HUAWEI-Vlanif50]vrrp vrid 50 virtual-ip 192.168.50.254
[HUAWEI-Vlanif50]vrrp vrid 50 priority 120
[HUAWEI-Vlanif50]quit
[HUAWEI]interface Vlanif 100
[HUAWEI-Vlanif100]vrrp vrid 100 virtual-ip 192.168.100.254
[HUAWEI-Vlanif100]vrrp vrid 100 priority 120
[HUAWEI-Vlanif100]return
<HUAWEI>save
Warning: The current configuration will be written to the device. Continue? [Y/N]:Y
<HUAWEI>


核心交换机1配置完成


核心交换机2配置:
//建立VLAN
<HUAWEI>system-view immediately    //CE系列设备需要增加immediately进入实时生效模式
[HUAWEI]vlan batch 10 20 30 40 50 100
[HUAWEI]

//进入SVI接口配置地址
[HUAWEI]interface Vlanif 10
[HUAWEI-Vlanif10]ip address 192.168.10.253 24
[HUAWEI-Vlanif10]quit
[HUAWEI]interface Vlanif 20
[HUAWEI-Vlanif20]ip address 192.168.20.253 24
[HUAWEI-Vlanif20]quit
[HUAWEI]interface Vlanif 30
[HUAWEI-Vlanif30]ip address 192.168.30.253 24
[HUAWEI-Vlanif30]quit
[HUAWEI]interface Vlanif 40
[HUAWEI-Vlanif40]ip address 192.168.40.253 24
[HUAWEI-Vlanif40]quit
[HUAWEI]interface Vlanif 50
[HUAWEI-Vlanif50]ip address 192.168.50.253 24
[HUAWEI-Vlanif50]quit
[HUAWEI]interface Vlanif 100
[HUAWEI-Vlanif100]ip address 192.168.100.253 24
[HUAWEI-Vlanif100]quit
[HUAWEI]

//与其他交换机互联端口设为Trunk:
[HUAWEI]interface Eth-Trunk 1
[HUAWEI-Eth-Trunk1]mode lacp-static
[HUAWEI-Eth-Trunk1]trunkport GE 1/0/1 to 1/0/2
[HUAWEI-Eth-Trunk1]port link-type trunk
[HUAWEI-Eth-Trunk1]port trunk allow-pass vlan 10 20 30 40 50 100
[HUAWEI-Eth-Trunk1]quit
[HUAWEI]interface Eth-Trunk 2
[HUAWEI-Eth-Trunk2]mode lacp-static
[HUAWEI-Eth-Trunk2]trunkport GE 1/0/3 to 1/0/4
[HUAWEI-Eth-Trunk2]port link-type trunk
[HUAWEI-Eth-Trunk2]port trunk allow-pass vlan 10 20 30 40 50 100
[HUAWEI-Eth-Trunk2]quit
[HUAWEI]

//配置MSTP:
[HUAWEI]stp mode mstp
[HUAWEI]stp region-configuration
[HUAWEI-mst-region]instance 1 vlan 10 20 30
[HUAWEI-mst-region]instance 2 vlan 40 50 100
[HUAWEI-mst-region]revision-level 1
[HUAWEI-mst-region]region-name test
[HUAWEI-mst-region]active region-configuration        //部分型号没有此命令
[HUAWEI-mst-region]quit
[HUAWEI]

//配置MSTP优先级(方法1):
[HUAWEI]stp instance 1 priority 8192
[HUAWEI]stp instance 2 priority 4096
[HUAWEI]

//配置MSTP优先级(方法2):
[HUAWEI]stp instance 1 root secondary
[HUAWEI]stp instance 2 root primary
[HUAWEI]

//启动生成树协议:
[HUAWEI]stp enable
Warning: The global STP state will be changed. Continue? [Y/N]:Y
[HUAWEI]

//配置VRRP:
[HUAWEI]interface Vlanif 10
[HUAWEI-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
[HUAWEI-Vlanif10]vrrp vrid 10 priority 120
[HUAWEI-Vlanif10]quit
[HUAWEI]interface Vlanif 20
[HUAWEI-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.254
[HUAWEI-Vlanif20]vrrp vrid 20 priority 120
[HUAWEI-Vlanif20]quit
[HUAWEI]interface Vlanif 30
[HUAWEI-Vlanif30]vrrp vrid 30 virtual-ip 192.168.30.254
[HUAWEI-Vlanif30]vrrp vrid 30 priority 120
[HUAWEI-Vlanif30]quit
[HUAWEI]interface Vlanif 40
[HUAWEI-Vlanif40]vrrp vrid 40 virtual-ip 192.168.40.254
[HUAWEI-Vlanif40]vrrp vrid 40 priority 150
[HUAWEI-Vlanif40]quit
[HUAWEI]interface Vlanif 50
[HUAWEI-Vlanif50]vrrp vrid 50 virtual-ip 192.168.50.254
[HUAWEI-Vlanif50]vrrp vrid 50 priority 150
[HUAWEI-Vlanif50]quit
[HUAWEI]interface Vlanif 100
[HUAWEI-Vlanif100]vrrp vrid 100 virtual-ip 192.168.100.254
[HUAWEI-Vlanif100]vrrp vrid 100 priority 150
[HUAWEI-Vlanif100]return
<HUAWEI>save
Warning: The current configuration will be written to the device. Continue? [Y/N]:Y
<HUAWEI>


核心交换机2配置完成

接入交换机配置:

//建立VLAN:
<HUAWEI>system-view immediately    //CE系列设备需要增加immediately进入实时生效模式
[HUAWEI]vlan batch 10 20 30 40 50 100
[HUAWEI]

//将VLAN划分到接口:
[HUAWEI]interface range GE 1/0/1 to GE 1/0/4
[HUAWEI-port-group]port link-type access
[HUAWEI-port-group]port default vlan 10
[HUAWEI-port-group]quit
[HUAWEI]interface range GE 1/0/5 to GE 1/0/8
[HUAWEI-port-group]port link-type access
[HUAWEI-port-group]port default vlan 20
[HUAWEI-port-group]quit
[HUAWEI]interface range GE 1/0/9 to GE 1/0/12
[HUAWEI-port-group]port link-type access
[HUAWEI-port-group]port default vlan 30
[HUAWEI-port-group]quit
[HUAWEI]interface range GE 1/0/13 to GE 1/0/16
[HUAWEI-port-group]port link-type access
[HUAWEI-port-group]port default vlan 40
[HUAWEI-port-group]quit
[HUAWEI]interface range GE 1/0/17 to GE 1/0/20
[HUAWEI-port-group]port link-type access
[HUAWEI-port-group]port default vlan 50
[HUAWEI-port-group]quit

//与其他交换机互联接口设为Trunk:
[HUAWEI]interface Eth-Trunk 1
[HUAWEI-Eth-Trunk1]mode lacp-static
[HUAWEI-Eth-Trunk1]trunkport GE 1/0/21 to 1/0/22
[HUAWEI-Eth-Trunk1]port link-type trunk
[HUAWEI-Eth-Trunk1]port trunk allow-pass vlan 10 20 30 40 50 100
[HUAWEI-Eth-Trunk1]quit
[HUAWEI]interface Eth-Trunk 2
[HUAWEI-Eth-Trunk2]mode lacp-static
[HUAWEI-Eth-Trunk2]trunkport GE 1/0/23 to 1/0/24
[HUAWEI-Eth-Trunk2]port link-type trunk
[HUAWEI-Eth-Trunk2]port trunk allow-pass vlan 10 20 30 40 50 100
[HUAWEI-Eth-Trunk2]quit

//配置MSTP:
[HUAWEI]stp mode mstp
[HUAWEI]stp region-configuration
[HUAWEI-mst-region]instance 1 vlan 10 20 30
[HUAWEI-mst-region]instance 2 vlan 40 50 100
[HUAWEI-mst-region]revision-level 1
[HUAWEI-mst-region]region-name test
[HUAWEI-mst-region]active region-configuration        //部分型号没有此命令
[HUAWEI-mst-region]quit
[HUAWEI]

//启动生成树协议:
[HUAWEI]stp enable
Warning: The global STP state will be changed. Continue? [Y/N]:Y
[HUAWEI]

//接入终端接口配置为边缘端口:
[HUAWEI]interface range GE 1/0/1 to GE 1/0/20        //部分型号无法使用range参数进入多个接口
[HUAWEI-port-group]stp edged-port enable
[HUAWEI-port-group]quit
[HUAWEI]


接入交换机配置完成
相关推荐
科技块儿1 小时前
2026年我会推荐哪些IP归属地查询网站?
网络·ip地址·ip归属地·运维工具·网络工具·实用网站·2026工具推荐
米羊1211 小时前
已有安全措施确认(中)
网络
听麟2 小时前
HarmonyOS 6.0+ 跨端智慧政务服务平台开发实战:多端协同办理与电子证照管理落地
笔记·华为·wpf·音视频·harmonyos·政务
前端世界2 小时前
从单设备到多设备协同:鸿蒙分布式计算框架原理与实战解析
华为·harmonyos
迎仔2 小时前
A-算力中心网络隔离总览:数字世界的“酒店房间“
网络
宝塔面板2 小时前
AllinSSL 一站式搞定 SSL 自动续期:永久免费,开源可自托管
网络·网络协议·ssl
csdn今天倒闭了吗2 小时前
飞牛lucky配置ipv6 ddns+ssl+反向代理
网络·网络协议·ssl
强风7943 小时前
Linux-网络层
网络
独行soc3 小时前
2026年渗透测试面试题总结-19(题目+回答)
android·网络·安全·web安全·渗透测试·安全狮
_Johnny_3 小时前
ETCD 配额/空间告警模拟方案
网络·数据库·etcd