与友商对接 IPSec 的注意事项
与友商对接 IPSec 的注意事项
由于每个厂商的地址组在 IPSec 协商中封装的格式可能不一致(FortiGate 使用地址组时,二阶段只使用一个 SA 包含多个网段,不会切割为多个 SA),可能导致协商失败或隧道翻转等现象,二阶段感兴趣流如果存在多对网段,请不要使用地址组作为第二阶段感兴趣流。请使用多个 Subnet 的作为二阶段感兴趣流的模式。
由于每个厂商对两端 SA 重协商时间不一致时的处理方法不一致(FortiGate 会使用双方 SA 重协商较小的时间作为自己的 SA 重协商时间),两端的一、二阶段 SA 重协商时间请尽量配置为相同的时间。
如果 IPSec 与友商对接时选择证书认证,可能会出现连接无法建立的情况。
在 FortiGate 的 IPSec Debug 信息中,如果看到如下报错:
FortiGate # diagnose debug application ike -1 FortiGate # diagnose debug enable RenHangNewVPN: 7913020: received p1 notify type INITIAL-CONTACT //RenHangNewVPN: 7913020: peer identifier IPV4_ADDR 54.121.33.6// RenHangNewVPN: 7913020: Validating X.509 certificate //RenHangNewVPN: 7913020: peer cert, subject='IPSECVPN', issuer='CFIT'// //RenHangNewVPN: 7913020: peer ID does not match cert// RenHangNewVPN: 7913020: certificate validation failed RenHangNewVPN: 7913020: info_send_n1, type 20 ......这是由于 FortiGate 选择证书认证时,默认会开启证书 ID(subject 或称为 CN)与对端 ID 的一致性检查(符合 RFC 4945)。当对端 IPSec 设备发送的 ID(此例中为 IPv4 54.121.33.6)与对端发送的证书的 subject(此例中为“IPSECVPN”)不一致时,会认证失败。
config vpn ipsec phase1-interface edit "FGT110" set cert-id-validation enable //使用证书认证后默认开启// next end当然,FortiGate 在开启 IPSec 证书认证时,会自动将本端 ID 修改为“asn1dn”类型,并将本端证书的 subject 复制到本端 ID 中,不会使用默认的本端 IPv 地址作为本端 ID(符合 RFC 4945)。
config vpn ipsec phase1-interface edit "FGT110" set interface "port8" set authmethod signature set peertype any set net-device disable set proposal aes128-sha256 aes256-sha256 aes128-sha1 aes256-sha1 set localid "FGT200” //配置locaid-type asn1dn后自动从本端证书的subject中读取后配置// set localid-type asn1dn //开启证书认证后自动配置// set comments "VPN: FGT110 (Created by VPN wizard)" set remote-gw 192.168.8.111 set certificate "FGT200" next end所以当 IPSec 两端均为 FortiGate 时,如果没有手工更改 ID 配置,连接是可以正常建立的。但如果对端设备为友商设备,可能不会遵守 RFC 4945,仍然使用 IP 地址作为 ID 发送至 FortiGate,这样就会导致协商失败。
解决办法:
是在 FortiGate 上关闭证书 ID 与对端 ID 的一致性检查。
config vpn ipsec phase1-interface edit "FGT110" set cert-id-validation disable next end或是在对端友商设备上配置 ID 类型为 asn1dn,ID 内容为其证书的 subject(如果友商设备支持此配置)。