配置VRRP与接口联动功能
组网需求
VRRP无法感知非VRRP备份组所在接口的状态变化,当上行接口出现故障时,VRRP无法感知,从而导致业务中断。通过配置VRRP监视上行接口,当接口Down时,VRRP备份组的Master设备降低优先级,并通过VRRP通告报文进行主备协商后,实现主备切换,承载流量转发。
如图1所示,主机HostA通过缺省网关访问主机HostB。在DeviceA和DeviceB上配置VRRP备份组,其中DeviceA为Master设备,DeviceB为Backup设备。从主机HostA到主机HostB的流量路径为:HostA->DeviceA->DeviceC->HostB。当DeviceA与DeviceC之间链路出现故障时,从主机HostA到主机HostB的流量会丢失。为防止此种情况发生,可以配置VRRP备份组监视接口功能。
配置注意事项
DeviceA的接口100GE1/0/1和DeviceB的接口100GE1/0/1的IP地址必须在相同的网段内。
为了提升安全性,在配置该示例时推荐配置VRRP安全策略,详细配置方式请参见“举例:配置VRRP主备备份”。
操作步骤
- 配置DeviceA、DeviceB和DeviceC各接口的IP地址,并配置采用OSPF协议进行互连。
<HUAWEI> system-view [~HUAWEI] sysname DeviceA [*HUAWEI] commit [~DeviceA] interface 100ge 1/0/1 [~DeviceA-100GE1/0/1] undo portswitch [*DeviceA-100GE1/0/1] ip address 10.1.1.1 24 [*DeviceA-100GE1/0/1] quit [*DeviceA] interface 100ge 1/0/2 [*DeviceA-100GE1/0/2] undo portswitch [*DeviceA-100GE1/0/2] ip address 192.168.1.1 24 [*DeviceA-100GE1/0/2] quit [*DeviceA] ospf 1 [*DeviceA-ospf-1] area 0 [*DeviceA-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255 [*DeviceA-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255 [*DeviceA-ospf-1-area-0.0.0.0] quit [*DeviceA-ospf-1] quit [*DeviceA] commit
# 配置DeviceB。
<HUAWEI> system-view [~HUAWEI] sysname DeviceB [*HUAWEI] commit [~DeviceB] interface 100ge 1/0/1 [~DeviceB-100GE1/0/1] undo portswitch [*DeviceB-100GE1/0/1] ip address 10.1.1.2 24 [*DeviceB-100GE1/0/1] quit [*DeviceB] interface 100ge 1/0/2 [*DeviceB-100GE1/0/2] undo portswitch [*DeviceB-100GE1/0/2] ip address 192.168.2.1 24 [*DeviceB-100GE1/0/2] quit [*DeviceB] ospf 1 [*DeviceB-ospf-1] area 0 [*DeviceB-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255 [*DeviceB-ospf-1-area-0.0.0.0] network 192.168.2.0 0.0.0.255 [*DeviceB-ospf-1-area-0.0.0.0] quit [*DeviceB-ospf-1] quit [*DeviceB] commit
# 配置DeviceC。
<HUAWEI> system-view [~HUAWEI] sysname DeviceC [*HUAWEI] commit [~DeviceC] interface 100ge 1/0/1 [~DeviceC-100GE1/0/1] undo portswitch [*DeviceC-100GE1/0/1] ip address 192.168.1.2 24 [*DeviceC-100GE1/0/1] quit [*DeviceC] interface 100ge 1/0/2 [*DeviceC-100GE1/0/2] undo portswitch [*DeviceC-100GE1/0/2] ip address 192.168.2.2 24 [*DeviceC-100GE1/0/2] quit [*DeviceC] interface 100ge 1/0/3 [*DeviceC-100GE1/0/3] undo portswitch [*DeviceC-100GE1/0/3] ip address 172.16.1.1 24 [*DeviceC-100GE1/0/3] quit [*DeviceC] ospf 1 [*DeviceC-ospf-1] area 0 [*DeviceC-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255 [*DeviceC-ospf-1-area-0.0.0.0] network 192.168.2.0 0.0.0.255 [*DeviceC-ospf-1-area-0.0.0.0] network 172.16.1.0 0.0.0.255 [*DeviceC-ospf-1-area-0.0.0.0] quit [*DeviceC-ospf-1] quit [*DeviceC] commit
- 配置VRRP备份组。
# 在DeviceA上配置VRRP备份组1,并配置DeviceA在该备份组中的优先级为120,确保DeviceA为Master设备。
[~DeviceA] interface 100ge 1/0/1 [~DeviceA-100GE1/0/1] vrrp vrid 1 virtual-ip 10.1.1.111 [*DeviceA-100GE1/0/1] vrrp vrid 1 priority 120 [*DeviceA-100GE1/0/1] quit [*DeviceA] commit
# 在DeviceB上配置VRRP备份组1,DeviceB在该备份组中使用缺省优先级,确保DeviceB为Backup设备。
[~DeviceB] interface 100ge 1/0/1 [~DeviceB-100GE1/0/1] vrrp vrid 1 virtual-ip 10.1.1.111 [*DeviceB-100GE1/0/1] quit [*DeviceB] commit
- 配置VRRP与接口联动功能。
[~DeviceA] interface 100ge 1/0/1 [~DeviceA-100GE1/0/1] vrrp vrid 1 track interface 100ge 1/0/2 reduce 30 [*DeviceA-100GE1/0/1] quit [*DeviceA] commit
检查配置结果
# 查看备份组监视的接口和接口状态。以DeviceA的显示结果为例。
[~DeviceA] display vrrp verbose
100GE1/0/1 | Virtual Router 1
State : Master
Virtual IP : 10.1.1.111
Master IP : 10.1.1.1
Local IP : 10.1.1.1
PriorityRun : 120
PriorityConfig : 120
MasterPriority : 120
Preempt : YES Delay Time : 0s Remain : --
Hold Multiplier : 4
TimerRun : 1s
TimerConfig : 1s
Auth Type : NONE
Virtual MAC : 00-e0-fc-12-78-90
Check TTL : YES
Config Type : Normal
Track IF : 100GE1/0/2
Priority Reduced :30
IF State : UP
Create Time : 2020-12-29 05:41:23
Last Change Time : 2020-12-29 05:41:33
# 对DeviceA的100GE1/0/2接口执行shutdown操作,模拟链路故障。
[~DeviceA] interface 100ge 1/0/2 [~DeviceA-100GE1/0/2] shutdown [*DeviceA-100GE1/0/2] quit [*DeviceA] commit
# 模拟链路故障后,在DeviceA和DeviceB上查看VRRP备份组的状态。
[~DeviceA] display vrrp verbose
100GE1/0/1 | Virtual Router 1
State : Backup
Virtual IP : 10.1.1.111
Master IP : 10.1.1.2
Local IP : 10.1.1.1
PriorityRun : 90
PriorityConfig : 120
MasterPriority : 100
Preempt : YES Delay Time : 0s Remain : --
Hold Multiplier : 4
TimerRun : 1s
TimerConfig : 1s
Auth Type : NONE
Virtual MAC : 00-e0-fc-12-78-90
Check TTL : YES
Config Type : Normal
Track IF : 100GE1/0/2 Priority Reduced :30
IF State : DOWN
Create Time : 2020-12-29 05:41:23
Last Change Time : 2020-12-29 05:41:33
可以看出,DeviceA上VRRP备份组的状态为Backup,DeviceB上VRRP备份组的状态为Master。
配置脚本
-
# sysname DeviceA # interface 100GE1/0/1 undo portswitch 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 track interface 100ge 1/0/2 reduce 30 # interface 100GE1/0/2 undo portswitch ip address 192.168.1.1 255.255.255.0 # 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
-
# sysname DeviceB # interface 100GE1/0/1 undo portswitch ip address 10.1.1.2 255.255.255.0 vrrp vrid 1 virtual-ip 10.1.1.111 # interface 100GE1/0/2 undo portswitch ip address 192.168.2.1 255.255.255.0 # 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
-
DeviceC
# sysname DeviceC # interface 100GE1/0/1 undo portswitch ip address 192.168.1.2 255.255.255.0 # interface 100GE1/0/2 undo portswitch ip address 192.168.2.2 255.255.255.0 # interface 100GE1/0/3 undo portswitch ip address 172.16.1.1 255.255.255.0 # ospf 1 area 0.0.0.0 network 192.168.1.0 0.0.0.255 network 192.168.2.0 0.0.0.255 network 172.16.1.0 0.0.0.255 # return
