Solution

  1. 通过在IPSec phase2-interface中,开启ipv4-df功能。
  2. 开启后,FortiGate发出的ESP报文会在封装的IP头部中,将DF位置1,不允许传输路径中的设备对ESP包进行分片。当ESP包经过MTU比自身小的设备接口时,该设备会丢弃ESP包,并通过ICMP返回自己接口的MTU值(fragmentation needed and DF set(Code4))。
  3. FortiGate收到该ICMP后,得到该设备接口的MTU,并降低IPSec Tunnel接口的MTU以适应该MTU值,即为当前获取到的Tunnel PMTU,防止该路径设备接口上的ESP被分片。
  4. FortiGate继续以调整后的Tunnel PMTU预封装原始数据,再封装ESP包并发送。
  5. 如果没有再遇到更小的设备接口MTU,则ESP包可以不分片到达IPSec对端。如果后续路径遇到了更小的设备接口MTU,则IPSec会重复学习直到学习到路径上最小的Tunnel MTU,该最小的Tunnel MTU即为Tunnel PMTU。

Topology

Untitled

Configuration

如何开启ipv4-df功能。

config vpn ipsec phase1-interface
    edit "ToR2"
        **set ip-fragmentation pre-encapsulation**
    next
end
config vpn ipsec phase2-interface
    edit "ToR2"
        **set ipv4-df enable**
    next
end

<aside> 💡 开启ipv4-df的同时,也必须开启pre-encapsulation。否则,使用post-encapsulation的同时开启ipv4-df,本身就可能发出ESP分片包,由于设置了DF位,FortiGate自身将无法对ESP包进行分片并发出。 参考Mantis ID 0748811,"When ipv4-df is enable, it only works with "set ip-fragmentation pre-encapsulation", if with default setting post-encapsulation, since DF is set, FGT actually won't be able to do fragmentation for the ESP."

</aside>

<aside> 💡 请注意,中间设备Router必须开启发送ICMP PMTU的功能,才能返回该种类型的ICMP,在FortiGate中,可以在全局配置下配置“set send-pmtu-icmp enable”开启(默认开启)。

</aside>

config system global
	**set send-pmtu-icmp enable**
end

Test Steps

  1. 首先查看在未开启ipv4-df时,FW1上Tunnel的相关的MTU与PMTU值,以及路径上的抓包情况(Router的port8的MTU设置为1400)。