由于VRRP封装的VGMP报文是组播报文,不能跨越三层传输设备,为此,在原有的IP报头上增加了UDP头和VGMP扩展头,VGMP内部报文的格式没有变化,即VGMP单播报文。
IP报文头 | ||||
Source Port | Destination Port | |||
Packet Length | Checksum | |||
Version | Type | Data Length | ||
Magic Code | ||||
Checksum | ||||
HRP Data |
Type字段定义了多种报文类型:
当Type为1时,报文封装成心跳探测报文。
当Type为1时,报文封装成心跳探测报文:检测对端设备的心跳口能否正常接收本段设备的报文,以确定是否有心跳口可以使用
当Type为5时,报文封装成一致性检查报文:检测双机热备状态下的两台防火墙的双机热备和策略配置是否一致,如安全策略、NAT等。
当Type为2时,VRRP进一步封装VGMP头,并根据VGMP报文中的Vtype字段进行区分。
VGMP报文:两台防火墙之间的vgmp组协商主备。
HRP心跳报文:探测对端的VGMP组是否处于工作状态,状态为active的VGMP组会每隔一段时间(缺省1s)向对端的vgmp组发送hrp心跳报文,用来通知本端的VGMP组状态和优先级。如果状态为standby的VGMP在三个周期内没有收到对端发送的HRP心跳报文,就认为对端VGMP组故障,将自身状态切换到active。
HRP数据报文:在VGMP报文头后增加HRP报文头,才能封装成HRP数据报文,HRP数据报文用来在主备设备之间的数据备份,包括命令行配置的备份和各种状态信息的备份。
1、心跳丢失
通过对端的心跳报文判断对端是否正常运行,是否需要进行故障切换,两端互相发送心跳报文,若连续5个周期没有收到对端的心跳报文,就可以判断其故障,进行故障切换。默认周期为1000ms。
2、VGMP组状态变化
防火墙通过心跳线接收对端发送的VGMP报文,了解其优先级,比较彼此的优先级大小确定是否要进行故障切换,一端防火墙的接口或者链路发生故障时,VGMP组优先级会降低,若本端VGMP组优先级低于对端,VGMP组切换为standby状态,同时向对端发送一个VGMP报文,进行故障切换。
故障事件 | 故障场景 | 对VGMP组优先级的影响 |
对于双CPU机型,从CPU故障 | null | VGMP组优先级降低2 |
VGMP组监控的接口故障 | 接口上配置了VRRP备份组 | 接口down,VGMP组降低:2×接口上VRRP备份组数 |
hrp track interface配置VGMP组监控物理接口状态 | 每一个物理接口为down时,VGMP组优先级降低2 | |
hrp track interface配置VGMP组监控Eth+Trunk接口状态 | 默认情况,VGMP组优先级降低:2×故障成员接口个数,若所有接口均down,则为2×(1+成员接口个数) 如果配置了undo hrp track-member enable则Eth-Trunk接口部分成员故障不影响VGMP优先级 |
|
接口上配置了VRRP备份组又hrp track interface配置VGMP组监控物理接口状态 | 接口故障时,采用累加方式,如接口配置了两个VRRP备份组,同时hrp track interface g1/0/1,故障时VGMP组优先级降低4+2=6 | |
hrp track vlan监控VLAN状态 | 加入该VLAN接口的故障时,每故障一个,VGMP组优先级降低2,若同时配置了hrp track interface g1/0/1,则采取累加。 | |
VGMP组监控链路故障 | IP-Link | 每一个IP-Link down时,VGMP组优先级降低2 |
BFD | 每一个BFD会话 down时,VGMP组优先级降低2 | |
OSPF | 每一个OSPF邻居状态从Full变为其他状态时,VGMP组优先级降低2 | |
BGP | 每一个BGP邻居状态从established变为其他状态时,VGMP组优先级降低2 |
组网类型 | 支持工作模式 | 故障监控方式 | 流量引导方式 |
防火墙业务接口工作在第三层,连接二层交换机 | 主备备份、负载分担 | 1、VRRP备份组监控设备自身接口 2、IP-Link监控远端接口(可选) 3、BFD监控远端接口(可选) |
主用设备向连接的交换机发送免费的ARP报文,刷新其MAC地址表 |
防火墙业务接口工作在第三层,连接路由器 | 主备备份、负载分担 | 1、直接监控设备接口 2、IP-Link监控远端接口(可选) 3、BFD监控远端接口(可选) 4、OSPF监控邻居(可选) 5、BGP监控邻居(可选) |
主用设备正常对外发布路由,备用设备发布的路由开销增加。 |
防火墙业务接口工作在第二层,连接二层交换机 | 主备备份 | 通过VLAN监控设备接口 | 主用设备的VLAN正常转发流量,备用设备的VLAN被禁用,切换时,主用设备的VLAN接口down一次并up一次,触发上下行二层设备MAC表更新。 |
防火墙业务接口工作在第二层,连接路由器 | 主备备份、负载分担 | 通过VLAN监控设备接口 | 主用设备的VLAN正常转发流量,备用设备的VLAN被禁用,切换时,主用设备的VLAN接口down一次并up一次,触发上下行三层设备路由收敛。 |
基于VRRP的主备备份双机热备、基于VRRP的负载分担双机热备
[R_A]ospf 1
[R_A-ospf-1]area 0
[R_A-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[R_A-ospf-1-area-0.0.0.0]network 10.1.2.0 0.0.0.255
[R_A-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[R_B]ospf 1
[R_B-ospf-1]area 0
[R_B-ospf-1-area-0.0.0.0]network 10.2.1.0 0.0.0.255
[R_B-ospf-1-area-0.0.0.0]network 10.2.2.0 0.0.0.255
[R_B-ospf-1-area-0.0.0.0]network 1.1.1.0 0.0.0.255
[FW1]ospf 1
[FW1-ospf-1]area 0
[FW1-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[FW1-ospf-1-area-0.0.0.0]network 10.2.1.0 0.0.0.255
[FW1-ospf-1-area-0.0.0.0]network 10.10.0.0 0.0.0.255
[FW2]ospf 1
[FW2-ospf-1]area 0
[FW2-ospf-1-area-0.0.0.0]network 10.2.2.0 0.0.0.255
[FW2-ospf-1-area-0.0.0.0]network 10.1.2.0 0.0.0.255
[FW2-ospf-1-area-0.0.0.0]network 10.10.0.0 0.0.0.255
[FW1]firewall zone trust
[FW1-zone-trust]add interface g1/0/1
[FW1-zone-trust]add interface g1/0/0
[FW1-zone-trust]firewall zone dmz
[FW1-zone-dmz]add interface g1/0/2
[FW2]firewall zone trust
[FW2-zone-trust]add interface g1/0/0
[FW2-zone-trust]add interface g1/0/1
[FW2-zone-trust]firewall zone dmz
[FW2-zone-dmz]add interface g1/0/2
//配置VGMP组直接监控接口
[FW1]interface g1/0/0
[FW1-GigabitEthernet1/0/0]hrp track interface g1/0/0
[FW1]interface g1/0/1
[FW1-GigabitEthernet1/0/1]hrp track interface g1/0/1
[FW2]hrp track interface g1/0/0
[FW2]hrp track interface g1/0/1
//配置自动调整Cost功能
[FW1]hrp adjust ospf-cost enable
[FW2]hrp adjust ospf-cost enable
//配置心跳口
[FW1]hrp interface g1/0/2 remote 10.10.0.2
[FW2]hrp interface g1/0/2 remote 10.10.0.1
//指定设备角色为备机,如果为负载分担模式,则不需要此配置
[FW2]hrp standby-device
//启动双机热备
[FW1]hrp enable
[FW2]hrp enable
HRP_M[FW1]display hrp state verbose
2024-01-04 14:25:03.050
Role: active, peer: standby
Running priority: 45000, peer: 45000
Backup channel usage: 0.00%
Stable time: 0 days, 0 hours, 0 minutes
Last state change information: 2024-01-04 14:24:27 HRP core state changed, old_
state = abnormal(standby), new_state = normal, local_priority = 45000, peer_prio
rity = 45000.
Configuration:
hello interval: 1000ms
preempt: 60s
mirror configuration: off
mirror session: off
track trunk member: on
auto-sync configuration: on
auto-sync connection-status: on
adjust ospf-cost: on
adjust ospfv3-cost: on
adjust bgp-cost: on
nat resource: off
Detail information:
GigabitEthernet1/0/0: up
GigabitEthernet1/0/1: up
ospf-cost: +0
ospfv3-cost: +0
bgp-cost: +0
HRP_S[FW2]display hrp state verbose
2024-01-04 14:25:32.770
Role: standby, peer: active
Running priority: 45000, peer: 45000
Backup channel usage: 0.00%
Stable time: 0 days, 0 hours, 1 minutes
Last state change information: 2024-01-04 14:24:27 HRP link changes to up.
Configuration:
hello interval: 1000ms
preempt: 60s
mirror configuration: off
mirror session: off
track trunk member: on
auto-sync configuration: on
auto-sync connection-status: on
adjust ospf-cost: on
adjust ospfv3-cost: on
adjust bgp-cost: on
nat resource: off
Detail information:
GigabitEthernet1/0/0: up
GigabitEthernet1/0/1: up
ospf-cost: +65500
ospfv3-cost: +65500
bgp-cost: +100
启动自动调整OSPF开销值功能hrp adjust ospf-cost enable:
①VGMP组为active状态时,按正常的ospf路由配置正常发布路由;
②VGMP组为standby状态时,默认情况下开销值调整为65500;
③VGMP组为load-balance状态时,默认按照正常的ospf路由的配置正常发布路由,若配置了hrp standby-device,调整方法与②相同。
HRP_M[FW1]display ip routing-table
2024-01-04 14:27:15.430
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 12 Routes : 12
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.0/24 OSPF 10 2 D 10.2.1.1 GigabitEthernet
1/0/1
HRP_S[FW2]display ip routing-table
2024-01-04 14:27:21.620
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 12 Routes : 14
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.0/24 OSPF 10 65501 D 10.2.2.1 GigabitEthernet
1/0/1
当FW1的上行端口故障。
HRP_M[FW1-GigabitEthernet1/0/1]shutdown
HRP_S[FW1]display ip routing-table
2024-01-04 14:36:40.270
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.0/24 OSPF 10 65503 D 10.1.1.1 GigabitEthernet
1/0/0
HRP_M[FW2]display ip routing-table
2024-01-04 14:37:46.950
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 11
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.0/24 OSPF 10 2 D 10.2.2.1 GigabitEthernet
1/0/1
[FW1]vlan 2
Info: This operation may take a few seconds. Please wait for a moment...done.
[FW1-vlan2]q
[FW1]interface g1/0/1
[FW1-GigabitEthernet1/0/1]portswitch
[FW1-GigabitEthernet1/0/1]port link-type trunk
[FW1-GigabitEthernet1/0/1]port trunk allow-pass vlan 2
[FW1-GigabitEthernet1/0/1]undo port trunk allow-pass vlan 1
[FW1-GigabitEthernet1/0/1]interface g1/0/0
[FW1-GigabitEthernet1/0/0]portswitch
[FW1-GigabitEthernet1/0/0]port link-type trunk
[FW1-GigabitEthernet1/0/0]port trunk allow-pass vlan 2
[FW1-GigabitEthernet1/0/0]undo port trunk allow-pass vlan 1
[FW1]hrp track vlan 2
[FW1]hrp interface g1/0/2 remote 10.10.0.2
[FW1]firewall zone dmz
[FW1-zone-dmz]add interface g1/0/2
[FW1]hrp enable
[FW2]vlan 2
Info: This operation may take a few seconds. Please wait for a moment...done.
[FW2-vlan2]q
[FW2]interface g1/0/1
[FW2-GigabitEthernet1/0/1]portswitch
[FW2-GigabitEthernet1/0/1]port link-type trunk
[FW2-GigabitEthernet1/0/1]port trunk allow-pass vlan 2
[FW2-GigabitEthernet1/0/1]undo port trunk allow-pass vlan 1
[FW2-GigabitEthernet1/0/1]interface g1/0/0
[FW2-GigabitEthernet1/0/0]portswitch
[FW2-GigabitEthernet1/0/0]port link-type trunk
[FW2-GigabitEthernet1/0/0]port trunk allow-pass vlan 2
[FW2-GigabitEthernet1/0/0]undo port trunk allow-pass vlan 1
[FW2]hrp track vlan 2
[FW2]hrp interface g1/0/2 remote 10.10.0.1
[FW2]hrp standby-device
[FW2]firewall zone dmz
[FW2-zone-dmz]add interface g1/0/2
[FW2]hrp enable
HRP_M[FW1]display hrp state verbose
2024-01-05 07:59:08.840
Role: active, peer: standby
Running priority: 45000, peer: 45000
Backup channel usage: 0.00%
Stable time: 0 days, 0 hours, 0 minutes
Last state change information: 2024-01-05 7:58:49 HRP core state changed, old_s
tate = abnormal(active), new_state = normal, local_priority = 45000, peer_priori
ty = 45000.
Configuration:
hello interval: 1000ms
preempt: 60s
mirror configuration: off
mirror session: off
track trunk member: on
auto-sync configuration: on
auto-sync connection-status: on
adjust ospf-cost: on
adjust ospfv3-cost: on
adjust bgp-cost: on
nat resource: off
Detail information:
GigabitEthernet1/0/0: up
GigabitEthernet1/0/1: up
vlan 2: enabled
ospf-cost: +0
ospfv3-cost: +0
bgp-cost: +0
HRP_M[FW1]
HRP_S[FW2]display hrp state verbose
2024-01-05 07:59:42.020
Role: standby, peer: active
Running priority: 45000, peer: 45000
Backup channel usage: 0.00%
Stable time: 0 days, 0 hours, 0 minutes
Last state change information: 2024-01-05 7:58:50 HRP link changes to up.
Configuration:
hello interval: 1000ms
preempt: 60s
mirror configuration: off
mirror session: off
track trunk member: on
auto-sync configuration: on
auto-sync connection-status: on
adjust ospf-cost: on
adjust ospfv3-cost: on
adjust bgp-cost: on
nat resource: off
Detail information:
GigabitEthernet1/0/0: up
GigabitEthernet1/0/1: up
vlan 2: disabled
ospf-cost: +65500
ospfv3-cost: +65500
bgp-cost: +100
FW1的vlan 2为enable,FW2的vlan 2为disabled。
当FW1发生故障时,FW1切换成备用设备,FW2成为主用设备。FW1切换成备用设备时,VLAN内所有接口都会Down然后Up一次。这会导致上下行交换机更新自身MAC转发表,重新学习MAC地址,将流量引导到FW2上。
此种组网不支持负载分担方式,如果工作于负载分担方式,则两台设备上的VLAN都被启用,都能够转发流量,整个网络就会形成环路。
配置与防火墙业务接口工作在第二层,连接交换机类似,不一样的地方在于主备备份组网不是通过hrp standby-device配置,而是通过合理配置OSPF路由开销值。
两台防火墙业务接口工作在第二层,均加入vlan2,分别连接路由器运行OSPF协议,上图为主备备份组网,路由器OSPF路由开销值设置为如图所示,对于AR2而言:AR2-AR1-FW1-AR4开销为110,AR2-FW2-AR3开销为200,由于前者开销小,因此会选择AR2-AR1-FW1-AR4,同理可得,对于AR1而言,会选择AR1-FW1-AR4到达外网。流量都被引导到FW1设备上,成为主用设备。
上图为负载分担组网,路由器OSPF路由开销值设置为如图所示,对于AR2而言:AR2-AR1-FW1-AR4开销为20,AR2-FW2-AR3开销为10,后者开销小,因此选择了FW2方向;对于AR1而言:AR1-FW1-AR4开销为10,AR1-AR2-FW2-AR3开销为20,前者开销小,因此选择了FW1方向,这就实现了负载分担的双机热备。
参考资料:防火墙和VPN技术与实践——李学昭