注:本文为华为设备配置 VRRP 实现设备网关冗余备份的两篇文章合辑。
华为设备配置 VRRP,实现设备网关冗余备份
原创 鸿鹄论坛 2023 年 05 月 25 日 10:00 山东
组网需求如图 1 所示,主机 HostA 通过缺省网关访问主机 HostB。RouterA 和 RouterB 组成 VRRP 备份组,作为 HostA 的缺省网关。
RouterA 为主设备,正常情况下,RouterA 承担网关工作;当 RouterA 出现故障时,RouterB 承担网关工作。RouterA 恢复后,能在 20 秒内抢占成为 Master。
图 1 主备备份 VRRP 组网图

操作步骤
RouterA 的配置
\#
interface Ethernet1/0/0
ip address 10.1.1.1 255.255.255.0 // 连接 HostA 的接口的 IP 地址
vrrp vrid 1 virtual-ip 10.1.1.111 // 配置虚拟网关地址
vrrp vrid 1 priority 120 // 配置 RouterA 在备份组中的优先级为 120,缺省情况下,优先级为 100,越大越优先
vrrp vrid 1 preempt-mode timer delay 20 // 配置抢占方式下的延迟时间
\#
interface Ethernet1/0/1
ip address 11.1.1.1 255.255.255.0 // 连接 HostB 的接口的 IP 地址
\#
RouterB 的配置
\#
interface Ethernet1/0/0
ip address 10.1.1.2 255.255.255.0 // 连接 HostA 的接口的 IP 地址
vrrp vrid 1 virtual-ip 10.1.1.111 // 配置虚拟网关地址
\#
interface Ethernet1/0/1
ip address 11.1.1.2 255.255.255.0 // 连接 HostB 的接口的 IP 地址
\#
验证配置结果
# 在 RouterA 上执行 display vrrp 命令可以查看 RouterA 上接口 Ethernet1/0/0 在 VRRP 备份组中的状态。其中 “state” 为 Master。
# 在 RouterB 上执行 display vrrp 命令可以查看 RouterB 上接口 Ethernet1/0/0 在 VRRP 备份组中的状态。其中 “state” 为 Backup。
配置注意事项
RouterA 和 RouterB 的虚拟网关地址要配置成一致。
需要配置 RouterA 和 RouterB 在备份组中的优先级,以确定主从关系。缺省情况下,优先级为 100,越大越优先。
确保 HostB 与 RouterA 之间、HostB 与 RouterB 之间分别路由可达。
可靠性配置 --VRRP 主备备份案例
原创 鸿鹄论坛 2024 年 01 月 08 日 10:56 山东
华为设备配置 VRRP 主备备份示例
VRRP 主备备份简介
通常,同一网段内的所有主机上都存在一条相同的、以网关为下一跳的缺省路由。主机发往其他网段的报文将通过缺省路由发往网关,再由网关进行转发,从而实现主机与外部网络的通信。当网关发生故障时,本网段内所有以网关为缺省路由的主机将无法与外部网络通信。增加出口网关是提高系统可靠性的常见方法,此时如何在多个出口之间进行选路就成为需要解决的问题。
VRRP 的出现很好的解决了这个问题。VRRP 能够在不改变组网的情况下,采用将多台路由设备组成一个虚拟路由器,通过配置虚拟路由器的 IP 地址为默认网关,实现默认网关的备份。当网关设备发生故障时,VRRP 机制能够选举新的网关设备承担数据流量,从而保障网络通信的可靠性。
在配置 VRRP 备份组内各交换机时,建议将 Backup 配置为立即抢占,即不延迟(延迟时间为 0),而将 Master 配置为延时抢占,并且配置 15 秒以上的延迟时间。这样配置的目的是为了在网络环境不稳定时,在上下行链路的状态恢复一致性期间等待一定时间,避免由于双方频繁抢占导致用户设备学习到错误的 Master 设备地址而导致流量中断问题。
抢占模式:在抢占模式下,如果 Backup 设备的优先级比当前 Master 设备的优先级高,则主动将自己切换成 Master。
非抢占模式:在非抢占模式下,只要 Master 设备没有出现故障,Backup 设备即使随后被配置了更高的优先级也不会成为 Master 设备。
配置注意事项
保证同一备份组的设备上配置相同的备份组号(virtual-router-id)。
V200R003C00 及之前的版本,仅 VLANIF 接口支持配置 VRRP 功能。V200R005C00 及之后的版本,VLANIF 接口和三层以太网接口均支持配置 VRRP 功能。
组网需求
如图 1 所示,HostA 通过 Switch 双归属到 SwitchA 和 SwitchB。为保证用户的各种业务在网络传输中不中断,需在 SwitchA 和 SwitchB 上配置 VRRP 主备备份功能。
正常情况下,主机以 SwitchA 为默认网关接入 Internet,当 SwitchA 故障时,SwitchB 接替 SwitchA 作为网关继续进行工作,实现网关的冗余备份。
SwitchA 故障恢复后,其延时 20 秒通过抢占的方式重新成为 Master,承担数据传输。
说明:
请确保该场景下互联接口的 STP 处于未使能状态。因为在使能 STP 的环形网络中,如果用交换机的 VLANIF 接口构建三层网络,会导致某个端口被阻塞,从而导致三层业务不能正常运行。
图 1 配置 VRRP 主备备份组网图

配置思路
采用 VRRP 主备备份实现网关冗余备份,配置思路如下:
配置各设备接口 IP 地址及路由协议,使各设备间网络层连通。
在 SwitchA 和 SwitchB 上配置 VRRP 备份组。其中,SwitchA 上配置较高优先级和 20 秒抢占延时,作为 Master 设备承担流量转发;SwitchB 上配置较低优先级,作为备用交换机,实现网关冗余备份。
操作步骤
配置设备间的网络互连
# 配置设备各接口的 IP 地址,以 SwitchA 为例。SwitchB 和 SwitchC 的配置与 SwitchA 类似,详见配置文件。
<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] vlan batch 100 300
[SwitchA] interface gigabitethernet 1/0/1
[SwitchA-GigabitEthernet1/0/1] port link-type hybrid
[SwitchA-GigabitEthernet1/0/1] port hybrid pvid vlan 300
[SwitchA-GigabitEthernet1/0/1] port hybrid untagged vlan 300
[SwitchA-GigabitEthernet1/0/1] quit
[SwitchA] interface gigabitethernet 1/0/2
[SwitchA-GigabitEthernet1/0/2] port link-type hybrid
[SwitchA-GigabitEthernet1/0/2] port hybrid pvid vlan 100
[SwitchA-GigabitEthernet1/0/2] port hybrid untagged vlan 100
[SwitchA-GigabitEthernet1/0/2] quit
[SwitchA] interface vlanif 100
[SwitchA-Vlanif100] ip address 10.1.1.1 24
[SwitchA-Vlanif100] quit
[SwitchA] interface vlanif 300
[SwitchA-Vlanif300] ip address 192.168.1.1 24
[SwitchA-Vlanif300] quit
# 配置 Switch 的二层转发功能。
<HUAWEI> system-view
[HUAWEI] sysname Switch
[Switch] vlan 100
[Switch-vlan100] quit
[Switch] interface gigabitethernet 1/0/1
[Switch-GigabitEthernet1/0/1] port link-type hybrid
[Switch-GigabitEthernet1/0/1] port hybrid pvid vlan 100
[Switch-GigabitEthernet1/0/1] port hybrid untagged vlan 100
[Switch-GigabitEthernet1/0/1] quit
[Switch] interface gigabitethernet 1/0/2
[Switch-GigabitEthernet1/0/2] port link-type hybrid
[Switch-GigabitEthernet1/0/2] port hybrid pvid vlan 100
[Switch-GigabitEthernet1/0/2] port hybrid untagged vlan 100
[Switch-GigabitEthernet1/0/2] quit
# 配置 SwitchA、SwitchB 和 SwitchC 间采用 OSPF 协议进行互连。以 SwitchA 为例,SwitchB 和 SwitchC 的配置与 SwitchA 类似,详见配置文件。
[SwitchA] ospf 1
[SwitchA-ospf-1] area 0
[SwitchA-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[SwitchA-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255
[SwitchA-ospf-1-area-0.0.0.0] quit
[SwitchA-ospf-1] quit
配置 VRRP 备份组
# 在 SwitchA 上创建 VRRP 备份组 1,配置 SwitchA 在该备份组中的优先级为 120,并配置抢占时间为 20 秒。
[SwitchA] interface vlanif 100
[SwitchA-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.111
[SwitchA-Vlanif100] vrrp vrid 1 priority 120 // 设备在 VRRP 备份组中的优先级缺省为 100,修改 Master 设备的优先级大于 Backup 设备
[SwitchA-Vlanif100] vrrp vrid 1 preempt-mode timer delay 20 // 设备在 VRRP 备份组中缺省采用立即抢占方式。修改 Master 设备的延迟抢占时间,以避免在网络环境不稳定时,由于双方频繁抢占而导致流量中断的问题
[SwitchA-Vlanif100] quit
# 在 SwitchB 上创建 VRRP 备份组 1,其在该备份组中的优先级采用缺省值 100(不需要配置)。
[SwitchB] interface vlanif 100
[SwitchB-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.111
[SwitchB-Vlanif100] quit
验证配置结果
# 完成上述配置以后,在 SwitchA 和 SwitchB 上分别执行 display vrrp 命令,可以看到 SwitchA 在备份组中的状态为 Master,SwitchB 在备份组中的状态为 Backup。
[SwitchA] display vrrp
Vlanif100 | Virtual Router 1
State : Master
Virtual IP : 10.1.1.111
Master IP : 10.1.1.1
PriorityRun : 120
PriorityConfig : 120
MasterPriority : 120
Preempt : YES Delay Time : 20 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0101
Check TTL : YES
Config type : normal-vrrp
Backup-forward : disabled
Create time : 2012-01-12 20:15:46
Last change time : 2012-01-12 20:15:46 [SwitchB] display vrrp
Vlanif100 | Virtual Router 1
State : Backup
Virtual IP : 10.1.1.111
Master IP : 10.1.1.1
PriorityRun : 100
PriorityConfig : 100
MasterPriority : 120
Preempt : YES Delay Time : 0 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0101
Check TTL : YES
Config type : normal-vrrp
Backup-forward : disabled
Create time : 2012-01-12 20:15:46
Last change time : 2012-01-12 20:15:46
# 在 SwitchA 和 SwitchB 上执行 display ip routing-table 命令,SwitchA 上可以看到路由表中有一条目的地址为虚拟 IP 地址的直连路由,而 SwitchB 上该路由为 OSPF 路由。SwitchA 和 SwitchB 上的显示信息如下。
[SwitchA] display ip routing-table
Route Flags: R - relay, D - download to fib
\------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 9 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/24 Direct 0 0 D 10.1.1.1 Vlanif100
10.1.1.1/32 Direct 0 0 D 127.0.0.1 Vlanif100
10.1.1.111/32 Direct 0 0 D 127.0.0.1 Vlanif100
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
172.16.1.0/24 OSPF 10 2 D 192.168.1.2 Vlanif300
192.168.1.0/24 Direct 0 0 D 192.168.1.1 Vlanif300
192.168.1.1/32 Direct 0 0 D 127.0.0.1 Vlanif300
192.168.2.0/24 OSPF 10 2 D 10.1.1.2 Vlanif100
OSPF 10 2 D 192.168.1.2 Vlanif300 [SwitchB] display ip routing-table
Route Flags: R - relay, D - download to fib
\------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 9 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/24 Direct 0 0 D 10.1.1.2 Vlanif100
10.1.1.2/32 Direct 0 0 D 127.0.0.1 Vlanif100
10.1.1.111/32 OSPF 10 2 D 10.1.1.1 Vlanif100
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
172.16.1.0/24 OSPF 10 2 D 192.168.2.2 Vlanif200
192.168.1.0/24 OSPF 10 2 D 10.1.1.1 Vlanif100
OSPF 10 2 D 192.168.2.2 Vlanif200
192.168.2.0/24 Direct 0 0 D 192.168.2.1 Vlanif200
192.168.2.1/32 Direct 0 0 D 127.0.0.1 Vlanif200
# 在 SwitchA 的接口 GE1/0/2 上执行 shutdown 命令,模拟 SwitchA 出现故障。
[SwitchA] interface gigabitethernet 1/0/2
[SwitchA-GigabitEthernet1/0/2] shutdown
[SwitchA-GigabitEthernet1/0/2] quit
# 在 SwitchB 上执行 display vrrp 命令查看 VRRP 状态信息,可以看到 SwitchB 的状态是 Master。
[SwitchB] display vrrp
Vlanif100 | Virtual Router 1
State : Master
Virtual IP : 10.1.1.111
Master IP : 10.1.1.2
PriorityRun : 100
PriorityConfig : 100
MasterPriority : 100
Preempt : YES Delay Time : 0 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0101
Check TTL : YES
Config type : normal-vrrp
Backup-forward : disabled
Create time : 2012-01-12 20:15:46
Last change time : 2012-01-12 20:18:40
# 在 SwitchA 的接口 GE1/0/2 上执行 undo shutdown 命令。
[SwitchA] interface gigabitethernet 1/0/2
[SwitchA-GigabitEthernet1/0/2] undo shutdown
[SwitchA-GigabitEthernet1/0/2] quit
# 等待 20 秒后,在 SwitchA 上执行 display vrrp 命令查看 VRRP 状态信息,可以看到 SwitchA 的状态恢复成 Master。
[SwitchA] display vrrp
Vlanif100 | Virtual Router 1
State : Master
Virtual IP : 10.1.1.111
Master IP : 10.1.1.1
PriorityRun : 120
PriorityConfig : 120
MasterPriority : 120
Preempt : YES Delay Time : 20 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0101
Check TTL : YES
Config type : normal-vrrp
Backup-forward : disabled
Create time : 2012-01-12 20:15:46
Last change time : 2012-01-12 20:20:56
配置文件
SwitchA 的配置文件
\#
sysname SwitchA
\#
vlan batch 100 300
\#
interface Vlanif100
ip address 10.1.1.1 255.255.255.0
vrrp vrid 1 virtual-ip 10.1.1.111
vrrp vrid 1 priority 120
vrrp vrid 1 preempt-mode timer delay 20
\#
interface Vlanif300
ip address 192.168.1.1 255.255.255.0
\#
interface GigabitEthernet1/0/1
port link-type hybrid
port hybrid pvid vlan 300
port hybrid untagged vlan 300
\#
interface GigabitEthernet1/0/2
port link-type hybrid
port hybrid pvid vlan 100
port hybrid untagged vlan 100
\#
ospf 1
area 0.0.0.0
network 10.1.1.0 0.0.0.255
network 192.168.1.0 0.0.0.255
\#
return
SwitchB 的配置文件
\#
sysname SwitchB
\#
vlan batch 100 200
\#
interface Vlanif100
ip address 10.1.1.2 255.255.255.0
vrrp vrid 1 virtual-ip 10.1.1.111
\#
interface Vlanif200
ip address 192.168.2.1 255.255.255.0
\#
interface GigabitEthernet1/0/1
port link-type hybrid
port hybrid pvid vlan 200
port hybrid untagged vlan 200
\#
interface GigabitEthernet1/0/2
port link-type hybrid
port hybrid pvid vlan 100
port hybrid untagged vlan 100
\#
ospf 1
area 0.0.0.0
network 10.1.1.0 0.0.0.255
network 192.168.2.0 0.0.0.255
\#
return
SwitchC 的配置文件
\#
sysname SwitchC
\#
vlan batch 200 300 400
\#
interface Vlanif200
ip address 192.168.2.2 255.255.255.0
\#
interface Vlanif300
ip address 192.168.1.2 255.255.255.0
\#
interface Vlanif400
ip address 172.16.1.1 255.255.255.0
\#
interface GigabitEthernet1/0/1
port link-type hybrid
port hybrid pvid vlan 300
port hybrid untagged vlan 300
\#
interface GigabitEthernet1/0/2
port link-type hybrid
port hybrid pvid vlan 200
port hybrid untagged vlan 200
\#
interface GigabitEthernet1/0/3
port link-type hybrid
port hybrid pvid vlan 400
port hybrid untagged vlan 400
\#
ospf 1
area 0.0.0.0
network 172.16.1.0 0.0.0.255
network 192.168.1.0 0.0.0.255
network 192.168.2.0 0.0.0.255
\#
return
Switch 的配置文件
\#
sysname Switch
\#
vlan batch 100
\#
interface GigabitEthernet1/0/1
port link-type hybrid
port hybrid pvid vlan 100
port hybrid untagged vlan 100
\#
interface GigabitEthernet1/0/2
port link-type hybrid
port hybrid pvid vlan 100
port hybrid untagged vlan 100
\#
return
via:
-
可靠性配置 --VRRP 主备备份案例 原创 鸿鹄论坛 2023 年 05 月 25 日 10:00 山东
-
华为设备配置 VRRP,实现设备网关冗余备份 原创 鸿鹄论坛 2024 年 01 月 08 日 10:56 山东
2216

被折叠的 条评论
为什么被折叠?



