IKE 流量启用策略路由
IKE 流量启用策略路由
功能简介
FortiGate 作为 VPN 网关主动发起 IKE 协商时,IKE 报文属于 FortiGate 本机发出的 local-out 流量。默认情况下,FortiGate 只根据路由表检查 VPN 网关地址是否可以通过一阶段配置中的出接口到达,不会检查策略路由。
当 VPN 对端网关需要通过策略路由从指定接口发出,而路由表中没有对应的活动路由时,可以启用 ike-policy-route,让 local-out IKE 流量同时检查策略路由。
相关信息
ike-policy-route 从 FortiOS 7.0.2 开始支持,配置位置为 config system settings。
适用场景
典型场景如下:
- IPSec 一阶段配置的出接口为
port1。 - 对端 VPN 网关地址为
198.51.100.10。 - 路由表中的默认路由从其他接口(例如
port3)出站。 - 通过策略路由指定访问
198.51.100.10/32时从port1发出。
如果未启用 ike-policy-route,即使已经配置策略路由,FortiGate 仍会因为路由表中没有经 port1 到达对端网关的活动路由,导致 IKE 报文发送失败。
配置实例
配置 VPN 一阶段,一阶段中的
interface指定 IKE 流量应从port1发出,remote-gw为对端 VPN 网关地址。config vpn ipsec phase1-interface edit "to-branch" set interface "port1" set peertype any set net-device disable set proposal aes256-sha256 set remote-gw 198.51.100.10 set psksecret <password> next end确认当前路由表。此示例中,路由表默认从
port3出站,没有经port1到达198.51.100.10的活动路由。get router info routing-table all Routing table for VRF=0 S* 0.0.0.0/0 [10/0] via 10.30.30.1, port3 C 10.10.10.0/24 is directly connected, port1 C 10.30.30.0/24 is directly connected, port3配置策略路由,指定 IKE 对端地址从
port1发出。config router policy edit 1 set dst "198.51.100.10/32" set gateway 10.10.10.1 set output-device "port1" next end启用
ike-policy-route,让 local-out IKE 流量检查策略路由。config system settings set ike-policy-route enable end如需恢复默认行为,可以将
ike-policy-route重新关闭。config system settings set ike-policy-route disable end
结果验证
启动 IKE debug,观察 IKE 报文发送过程。
diagnose debug application ike -1 diagnose debug enable启用前,如果 FortiGate 只检查路由表,IKE debug 中可能看到类似发送失败信息。
ike 0:to-branch: created connection: 10.10.10.2->198.51.100.10:500 ike 0:to-branch: initiator: main mode is sending 1st message... ike 0:to-branch: could not send IKE Packet(ident_i1send):10.10.10.2:500->198.51.100.10:500, len=572 vrf=0: error 101:Network is unreachable启用后,可以通过 debug 或抓包确认 IKE 报文已经从策略路由指定的接口发出。
diagnose sniffer packet any "host 198.51.100.10" 4 0 ainterfaces=[any] filters=[host 198.51.100.10] port1 out 10.10.10.2.500 -> 198.51.100.10.500: udp 572验证结束后关闭 debug。
diagnose debug disable diagnose debug reset
注意事项
ike-policy-route是全局配置,启用后会影响本机发起的 IKE 流量查找策略路由的行为。如果已存在旧的 IKE 会话,建议在维护窗口内清理对应会话。FortiGate 会周期性发送 IKE 流量,旧会话可能长期存在,导致新的策略路由查找行为不能立即生效。
diagnose sys session filter clear diagnose sys session filter src <IKE 本端源地址> diagnose sys session filter dst <IKE 对端网关地址> diagnose sys session filter dport <500 或 4500> diagnose sys session clear diagnose sys session filter clear使用 NAT-T 时,IKE 流量可能使用 UDP 4500,需要在过滤会话或抓包时同时关注 UDP 500 和 UDP 4500。