华为VRRP+MSTP组网实验

Eth-Trunk

SW1 和 SW2 分别通过 GE0/0/3,GE0/0/4 和 GE0/0/5 接口相互连接, 把这三个接口捆绑成一个逻辑接口,使用的模式为 static-lacp。

在SW1和SW2上都配置如下命令。

1
2
3
4
5
6
interface Eth-Trunk 1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
mode lacp-static
max active-linknumber 2
trunkport GigabitEthernet 0/0/3 0/0/4 0/0/5
1
2
3
[SW1-GigabitEthernet0/0/3]lacp priority 1000
[SW1-GigabitEthernet0/0/4]lacp priority 1500
[SW1-GigabitEthernet0/0/5]lacp priority 2000

接口都配置不同的优先级,主要作用是让ge 0/0/3和ge 0/0/4为活动端口,ge 0/0/5为备份端口,当端口端口其中一条链路断开时,ge 0/0/5口会迅速抢占成为活动端口。

如果有三台或者三台以上的设备时才都需要在全部设备配置LACP系统优先级,活动端口数量,抢占功能。

命令 作用
interface Eth-Trunk 1 进入以太网聚合接口配置模式
port link-type trunk 配置接口为聚合接口,并且设置链路类型为 Trunk
port trunk allow-pass vlan 2 to 4094 设置该聚合接口允许通过的 VLAN 范围为从 VLAN 2 到 VLAN 4094
mode lacp-static 将聚合接口的工作模式设置为静态 LACP 模式
max active-linknumber 2 设置该聚合接口最大的主动链路数为 2 条,这样两台设备之间最大可用的带宽为 2G。
trunkport GigabitEthernet 添加成员端口
lacp priority 4096 配置LACP系统优先级,使设备为主动端或者设置端口优先级
lacp preempt enable 开启抢占功能
lacp preempt delay 10 设置抢占时间为10秒

STP

所有的交换运行 MSTP,MSTP 域名为 huawei,修订等级为 1。
额外创建两个实例,将 VLAN10、20、30 划分进实例 1,VLAN50、60 划分 进实例 2。

在交换机进行相应的配置,使 PC 或者路由器接入立即能进入转发状态, 并且配置相应的保护功能,收到 BPDU 接口会被关闭。

所有的交换都配置如下指令:

1
2
3
4
5
6
stp region-configuration
region-name huawei
revision-level 1
instance 1 vlan 10 20 30
instance 2 vlan 50 60
active region-configuration
命令 作用
stp region-configuration 进入 STP 区域配置模式
region-name huawei 配置 STP 区域名称为 huawei
revision-level 1 配置 STP 区域的版本号为 1
instance 1 vlan 10 20 30 配置 STP 区域实例 1 包含 VLAN 10 20 30
instance 2 vlan 50 60 配置 STP 区域实例 2 包含 VLAN 50 60
active region-configuration 激活 STP 区域配置

dis stp instance 1 可用于显示 STP 区域实例 1 的状态信息

要求SW1为实例1的根桥,实例2的备份根桥;SW2为实例2的根 桥,实例 1 的备份根桥。

SW1:

1
2
stp instance 1 root primary
stp instance 2 root secondary

SW2:

1
2
stp instance 1 root secondary
stp instance 2 root primary

dis stp brief 可用于显示 STP 网络的摘要信息。

在交换机进行相应的配置,使 PC 或者路由器接入立即能进入转发状态, 并且配置相应的保护功能,收到 BPDU 接口会被关闭。

上行接口或接入或者汇聚的终端接口

1
2
interface GigabitEthernet0/0/2
stp edged-port enable
命令 作用
interface GigabitEthernet0/0/2 进入 GigabitEthernet0/0/2接口配置模式
stp edged-port enable 启用接口的边缘端口(Edge Port)功能,表示该接口连接的是一个非 STP 设备,可以避免该接口的状态从 Listening 状态切换到 Learning 状态

VRRP

SW1 和 SW2 分别存在 Vlanif10 20 30 50 60 ,分别作为各部门的网关, 要求使用 VRRP 技术实现网关的冗余备份。

SW1

1
2
3
4
5
6
7
8
9
10
11
12
13
interface Vlanif10
vrrp vrid 10 virtual-ip 192.168.10.254
vrrp vrid 10 priority 200
interface Vlanif20
vrrp vrid 20 virtual-ip 192.168.20.254
vrrp vrid 20 priority 200
interface Vlanif30
vrrp vrid 30 virtual-ip 192.168.30.254
vrrp vrid 30 priority 200
interface Vlanif50
vrrp vrid 50 virtual-ip 192.168.50.254
interface Vlanif60
vrrp vrid 60 virtual-ip 192.168.60.254

SW2

1
2
3
4
5
6
7
8
9
10
11
12
interface Vlanif10
vrrp vrid 10 virtual-ip 192.168.10.254
interface Vlanif20
vrrp vrid 20 virtual-ip 192.168.20.254
interface Vlanif30
vrrp vrid 30 virtual-ip 192.168.30.254
interface Vlanif50
vrrp vrid 50 virtual-ip 192.168.50.254
vrrp vrid 10 priority 200
interface Vlanif60
vrrp vrid 60 virtual-ip 192.168.60.254
vrrp vrid 10 priority 200
命令 作用
interface Vlanif10 进入 VLAN 10 虚拟接口的配置模式
vrrp vrid 10 virtual-ip 192.168.10.254 配置 VLAN 10 的虚拟路由器 ID 为10,id范围:1-255,虚拟 IP 地址为 192.168.10.254
vrrp vrid 10 priority 200 配置 VLAN 10 的虚拟路由器优先级为 200,默认100,越高越优先,优先范围:1-254

在 Vlanif10 20 30 50 60的master路由器分别使用 BFD 技术跟踪上行接口, 当上行链路断开时,能自动切换到备份路由器。

SW1:上行接口GigabitEthernet0/0/2

1
2
3
4
5
6
interface Vlanif10
vrrp vrid 10 track interface GigabitEthernet0/0/2 reduced 110
interface Vlanif20
vrrp vrid 20 track interface GigabitEthernet0/0/2 reduced 110
interface Vlanif30
vrrp vrid 30 track interface GigabitEthernet0/0/2 reduced 110

SW2:上行接口GigabitEthernet0/0/2

1
2
3
4
interface Vlanif50
vrrp vrid 50 track interface GigabitEthernet0/0/2 reduced 110
interface Vlanif60
vrrp vrid 60 track interface GigabitEthernet0/0/2 reduced 110
命令 作用
interface Vlanif10 进入 VLAN 10 虚拟接口的配置模式
vrrp vrid 10 track interface GigabitEthernet0/0/2 reduced 110 配置 VLAN 10 的虚拟路由器跟踪接口 GigabitEthernet0/0/2 的状态,当该接口down掉后,优先级减少110,将SW1 的虚拟路由器优先级从200减少为90,而SW2默认优先级为100,SW2优先级比SW1高,此时,SW2会抢占成为master。

华为VRRP+MSTP组网实验
https://kuan.pages.dev/article/738766b7.html
作者
IKun
发布于
2023年8月21日
许可协议