vrrp
Skill2 starsChanged 3 months agoMITView on GitHub
This skill should be used when the user asks to configure or troubleshoot VRRP (Virtual Router Redundancy Protocol) on Huawei CloudEngine / S series switches as gateway redundancy. Covers VRRPv2 (IPv4) / VRRPv3 (IPv4/IPv6), backup group, priority, preempt, track interface/BFD/NQA linkage, virtual IP ping, management VRRP, and load balancing with multiple groups. Applicable platforms S/CE switches (V200R011C10+/V200R022C00+) and USG firewalls (V500R005C20+/V600R007C20+).
In this repository16 other files it gives its agents.
- aaa-auth-configSkill
- attack-defenseSkill
- bgp-configSkill
- ha-hrpSkill
- health-checkSkill
- interface-configSkill
- ipsec-vpnSkill
- mirrorSkill
- nat-configSkill
- ospf-configSkill
- security-policySkill
- ssl-vpnSkill
- stack-istackSkill
- static-routeSkill
- vlan-configSkill
- wlan-ac-configSkill
The file
Files
华为交换机 VRRP 配置技能 (vrrp)
适用平台 S 系列 V200R011C10+ | CE 系列 V200R022C00+ 文档来源 华为产品文档 dc_cfg_vrrp_*
VRRP 给终端提供虚拟网关 主备路由器对外表现为一台 终端无感知切换 是局域网三层高可用基础
触发场景
- 配置主备网关 高可用
- 终端网关切换不丝滑 丢包多
- VRRP 优先级 / 抢占调整
- VRRP 主备频繁切换
- VRRP + BFD 实现毫秒级切换
- VRRP + NQA 联动上联探测
- 负载分担(两组互为主备)
- 配置管理 VRRP(堆叠/集群管理用)
VRRP 版本对比
| 版本 | RFC | 支持协议 | 备注 |
| VRRPv2 | RFC 3768 | 仅 IPv4 | 默认 应用最广 |
| VRRPv3 | RFC 5798 | IPv4 + IPv6 | 双栈支持 改进了认证 |
如混合环境 推荐用 VRRPv3
基本概念
| 术语 | 解释 |
| VRID | 备份组号 1-255 同一备份组成员 VRID 一致 |
| 虚拟 IP | 虚 IP 终端网关 |
| 虚拟 MAC | 自动生成 0000-5e00-01XX(XX=VRID) |
| Master | 主 转发流量 |
| Backup | 备 监听 Master 心跳 |
| 优先级 | 0-255 默认 100 大优 0 表示放弃 |
| 抢占 | 高优先级设备恢复时自动接管 |
配置三步走
1 基础 VRRP(主路由器)
system-view
interface Vlanif 10
ip address 192.168.10.2 24
vrrp vrid 1 virtual-ip 192.168.10.1 # 虚 IP
vrrp vrid 1 priority 120 # 优先级 高
vrrp vrid 1 preempt-mode timer delay 30 # 抢占延时
quit2 配置备份路由器
system-view
interface Vlanif 10
ip address 192.168.10.3 24
vrrp vrid 1 virtual-ip 192.168.10.1 # 同一虚 IP
vrrp vrid 1 priority 100 # 优先级 低
quit终端 PC 网关:192.168.10.1(虚 IP)
3 验证
display vrrp
display vrrp brief
display vrrp interface Vlanif 10正常:主 State=Master 备 State=Backup
高级 联动 BFD(毫秒级切换)
# 1 配 BFD 会话
bfd
quit
bfd to_peer bind peer-ip 192.168.10.3 source-ip 192.168.10.2
discriminator local 1
discriminator remote 2
commit
quit
# 2 VRRP 跟踪 BFD
interface Vlanif 10
vrrp vrid 1 track bfd-session 1 reduced 30BFD down → 优先级减 30 → 主备切换(毫秒级)
联动 NQA(上联探测)
# 1 NQA 探测上联路由器
nqa test-instance admin to_uplink
test-type icmp
destination-address ipv4 10.1.1.1
frequency 5
start now
quit
# 2 VRRP 跟踪 NQA
interface Vlanif 10
vrrp vrid 1 track nqa admin to_uplink reduced 40上联失败 → 优先级减 40 → 让出主权
联动接口(跟踪上联接口)
interface Vlanif 10
vrrp vrid 1 track interface GigabitEthernet 0/0/24 reduced 30上联接口 down → 优先级减 30 → 切换
负载分担(两组互为主备)
让两台路由器都干活 提升资源利用
# 路由器 A
interface Vlanif 10
vrrp vrid 1 virtual-ip 192.168.10.1 priority 120 # A 主
vrrp vrid 2 virtual-ip 192.168.10.254 priority 100 # A 备
# 路由器 B
interface Vlanif 10
vrrp vrid 1 virtual-ip 192.168.10.1 priority 100 # B 备
vrrp vrid 2 virtual-ip 192.168.10.254 priority 120 # B 主终端一半网关用 .1 一半用 .254 → 流量分担
命令体系
VRRP 基础
| 命令 | 视图 | 说明 |
vrrp vrid <id> virtual-ip <ip> | interface | 创建备份组 |
vrrp vrid <id> priority <num> | interface | 优先级 默认 100 |
vrrp vrid <id> preempt-mode | interface | 抢占模式 默认开 |
vrrp vrid <id> preempt-mode timer delay <s> | interface | 抢占延时 |
vrrp vrid <id> timer advertise <s> | interface | 通告间隔 默认 1s |
vrrp vrid <id> authentication-mode { simple | md5 } <key> | interface | 认证 |
vrrp vrid <id> version { v2 | v3 } | interface | 版本 |
Track 联动
| 命令 | 视图 | 说明 |
vrrp vrid <id> track interface <if> reduced <num> | interface | 跟接口 失效减优先级 |
vrrp vrid <id> track interface <if> increased <num> | interface | UP 加优先级 |
vrrp vrid <id> track bfd-session <session-id> reduced <num> | interface | 跟 BFD |
vrrp vrid <id> track nqa <admin> <name> reduced <num> | interface | 跟 NQA |
vrrp vrid <id> track admin-vrrp interface <if> vrid <id> | interface | 跟管理 VRRP |
管理 VRRP(堆叠/集群)
| 命令 | 视图 | 说明 |
admin-vrrp vrid <id> | interface | 创建管理 VRRP |
vrrp vrid <id> track admin-vrrp ... | interface | 业务 VRRP 跟管理 VRRP |
平滑倒换
| 命令 | 视图 | 说明 |
vrrp vrid <id> shutdown | interface | 手动让出 |
undo vrrp vrid <id> shutdown | interface | 重新参与 |
vrrp recover-delay <s> | system | 上电后恢复延时 |
虚 IP Ping
| 命令 | 视图 | 说明 |
| vrrp virtual-ip ping enable | interface | 允许虚 IP 被 ping(默认禁) |
查看
| 命令 | 说明 |
| display vrrp | 全部 VRRP 备份组 |
| display vrrp brief | 简要 |
display vrrp interface <if> | 接口下 VRRP |
display vrrp vrid <id> | 单组详情 |
| display vrrp statistics | 协议统计 |
| display vrrp state-change | 状态变化历史 |
完整范式 主备 + BFD 联动 + 上联跟踪
需求:核心层两台 S6720 互为主备 终端网关用虚 IP 上联接 ISP 主备探测 BFD 毫秒切换
# 主 (R1)
system-view
sysname R1
interface Vlanif 10
ip address 192.168.10.2 24
vrrp vrid 1 virtual-ip 192.168.10.1
vrrp vrid 1 priority 120
vrrp vrid 1 preempt-mode timer delay 30
vrrp vrid 1 track interface GigabitEthernet 0/0/24 reduced 30
quit
bfd
bfd to_R2 bind peer-ip 192.168.10.3 source-ip 192.168.10.2
discriminator local 100
discriminator remote 200
commit
quit
interface Vlanif 10
vrrp vrid 1 track bfd-session 1 reduced 40
# 备 (R2)
system-view
sysname R2
interface Vlanif 10
ip address 192.168.10.3 24
vrrp vrid 1 virtual-ip 192.168.10.1
vrrp vrid 1 priority 100
vrrp vrid 1 track interface GigabitEthernet 0/0/24 reduced 30
bfd
bfd to_R1 bind peer-ip 192.168.10.2 source-ip 192.168.10.3
discriminator local 200
discriminator remote 100
commit常见陷阱
- 两端 VRID 不同 → 两台都是 Master(脑裂)
- 虚 IP 与物理 IP 网段不同 → 协商失败
- 两端优先级相同 → 比较 IP 大者胜 行为不可预期
- 没配 preempt delay → 主上电后立刻抢占 业务抖动
- 终端网关写成物理 IP → 失去高可用意义
- 通告间隔 advertise timer 两端不一致 → 协商异常
- BFD 没 commit → BFD 不生效 track 不工作
- NQA frequency 设 60s → 切换太慢
排查流程
VRRP 异常
|
v
[1] display vrrp → 看 State
|
├─ 两台都 Master → 走分支 A 脑裂
├─ 两台都 Backup → 走分支 B 都让出
├─ 主备颠倒 → 走分支 C 优先级问题
├─ 频繁切换 → 走分支 D 不稳定
└─ 切换后丢包 → 走分支 E 切换性能相关文件
- references/vrrp-commands.md 完整命令
- references/vrrp-troubleshooting.md 故障排查
⚠️ 平台差异
CE 系列特有:VRRP 负载分担管理组
CE 在标准 VRRP 之上引入了负载分担管理组,可让多台主路由器同时转发,自动按 MAC 分流:
interface Vlanif 10
vrrp vrid 1 virtual-ip 192.168.10.1 active
vrrp vrid 1 load-balance # 创建 VRRP 负载分担管理组
vrrp vrid 2 virtual-ip 192.168.10.1 standby
vrrp vrid 2 join load-balance-vrrp vrid 1 # 加入主管理组S 系列没有此特性,要做负载分担用经典「两组互为主备 + 终端分配不同网关」做。
CE 二阶段提交
配置后需 commit 才生效。
USG 防火墙 VRRP
- USG 支持 VRRP,命令与交换机基本一致(
vrrp vrid <id> virtual-ip <ip> active|standby) - 防火墙 VRRP 通常配合 HRP 双机热备 一起用(见 ha-hrp 技能)
- 单纯 VRRP 在防火墙上少用,因为 HRP 更完整(VRRP + VGMP + 会话同步)
- 不要在 HRP 已启用的接口上单独配 VRRP,否则冲突
VRRP track BFD 注意
- S 系列:BFD 联动配置见命令速查
- CE 系列:BFD 配置后需
commit - USG:通过 HRP track 实现,不直接用 VRRP track BFD
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

