GRE and IPsec Tunnel MTU, MSS Clamping, and Fragmentation
How to set MTU and TCP MSS clamp values for GRE and IPsec WAN tunnels so encapsulated traffic avoids drops, fragmentation, and failed connections.
This page summarizes Cloudflare documentation on maximum transmission unit (MTU) and maximum segment size (MSS) for traffic carried over Cloudflare WAN, Magic Transit, Cloudflare Mesh, and related GRE and IPsec tunnels. If ping works but HTTPS stalls, or small requests succeed while large transfers hang, the cause is often encapsulation overhead—not application failure.
MTU and MSS: why tunnel traffic needs smaller packets
Section titled “MTU and MSS: why tunnel traffic needs smaller packets”MTU is the largest Layer 3 packet a device accepts, including all headers and payload; MSS is the largest TCP payload in one segment (Layer 4). Cloudflare delivers these services by encapsulation: your packet is wrapped in extra headers before it crosses the Internet. That overhead shrinks the space left for your data on a 1,500-byte Internet path.
Because Cloudflare WAN wraps your traffic in additional headers (encapsulation), the effective space available for your original data in each packet is reduced. If you do not account for this overhead, packets may be too large for the network path and will be dropped or fragmented — leading to performance loss or failed connections.
— Cloudflare, Maximum transmission unit and maximum segment size
For IPv4 over a standard 1,500-byte MTU, a host typically advertises MSS 1,460 (1,500 minus 20-byte IP and 20-byte TCP headers). After a GRE tunnel adds 24 bytes (20-byte outer IPv4 + 4-byte GRE), the tunnel-side MTU becomes 1,476, and the matching TCP MSS in SYN packets should be 1,436.
One common misconception is that lowering MSS hurts throughput. Cloudflare notes a slight penalty is acceptable; leaving MTU/MSS unconfigured for your path is usually worse.
GRE versus IPsec encapsulation: encryption and MSS placement
Section titled “GRE versus IPsec encapsulation: encryption and MSS placement”Both protocols build logical point-to-point tunnels between Cloudflare and your edge. Choice affects setup and security, not only routing.
| Feature | GRE | IPsec |
|---|---|---|
| Encryption | No | Yes |
| Authentication | No | Pre-shared key (PSK) |
| Setup complexity | Simpler | Requires PSK exchange |
| Best for | Trusted networks, CNI connections | Internet-facing connections requiring encryption |
GRE is stateless and simpler to configure but does not encrypt traffic. IPsec encrypts traffic and authenticates the source, providing stronger security.
— Cloudflare, GRE and IPsec tunnels
GRE requires a static public IP and careful MTU planning (1,476 bytes MTU, MSS clamping at 1,436 bytes or lower). Use IPsec when encryption is required. See Configure tunnel endpoints and Connectivity options for tunnel types.
GRE tunnel MTU 1476 and MSS clamp 1436 bytes
Section titled “GRE tunnel MTU 1476 and MSS clamp 1436 bytes”On your edge router, apply the clamp on the GRE tunnel internal interface (where egress traffic traverses). Set the MSS clamp to 1,436 bytes. Some devices set this automatically after the tunnel comes up; verify on your platform.
On your edge router: Apply the clamp to the GRE tunnel internal interface (meaning where the egress traffic will traverse). Set the MSS clamp to 1,436 bytes.
— Cloudflare, Maximum transmission unit and maximum segment size
IPsec tunnel MTU and TCP MSS clamp 1360 bytes maximum
Section titled “IPsec tunnel MTU and TCP MSS clamp 1360 bytes maximum”IPsec MSS values are lower than GRE because the physical path sees encrypted packets, not cleartext TCP—MSS clamping does not apply the same way on the outer IPsec envelope.
On the IPsec tunnel internal interface, set the TCP MSS clamp to 1,360 bytes maximum. Confirm whether your firewall applies IPsec MSS clamping automatically; with IPsec inside GRE, you may need a manual clamp. Juniper SRX can scope clamping to IPsec only, e.g. set security flow tcp-mss ipsec-vpn mss 1360—see HPE Juniper Networking SRX Series Firewalls.
Cloudflare recommends a maximum TCP MSS clamp of 1360 bytes for IPsec tunnels. This value is below the 1382-byte MSS that AWS lists for AES-CBC with SHA-256 and NAT-T, so it is compatible with the cipher suite in this guide.
— Cloudflare, Amazon AWS Transit Gateway
Effective IPsec tunnel MTU is often cited around 1,400–1,436 bytes (varies by cipher); troubleshooting guides suggest verifying 1,476 for GRE and 1,400–1,450 for IPsec—see Troubleshoot IPsec tunnels.
Effective MTU and MSS clamp values by scenario
Section titled “Effective MTU and MSS clamp values by scenario”When you stack tunnels or use Cloudflare Mesh with Cloudflare One Client, overhead compounds. Connectivity options publishes effective values:
| Scenario | Effective MTU | MSS clamping |
|---|---|---|
| GRE tunnel | 1,476 bytes | 1,436 bytes or lower |
| IPsec tunnel | 1,400–1,436 bytes (varies by encryption) | 1,360–1,396 bytes |
| Cloudflare One Client behind Cloudflare WAN (double encapsulation) | ~1,300 bytes | Configure based on testing |
| Cloudflare Mesh to Cloudflare One Client | ~1,280 bytes | Configure based on testing; traffic may be encapsulated twice |
Configure MSS clamping on edge devices so TCP traffic does not depend on path fragmentation. Details: Get started (Cloudflare WAN) and Get started (Magic Transit).
MSS clamping: where to apply it on edge routers
Section titled “MSS clamping: where to apply it on edge routers”MSS clamping rewrites the TCP MSS option in transit so remote peers send segments that fit the path. It is TCP-only; UDP and other protocols need MTU sizing or fragmentation handling instead.
Cloudflare WAN and Magic Transit full-tunnel egress
Section titled “Cloudflare WAN and Magic Transit full-tunnel egress”For ingress + egress Magic Transit or Cloudflare WAN over GRE, clamp 1,436 on the Magic Transit / Cloudflare WAN GRE internal interface. For IPsec egress, clamp 1,360 maximum on the IPsec internal interface.
Router-specific steps differ by vendor; Get started points to common platforms (for example Cisco and Juniper MSS documentation via that page).
Magic Transit Direct Server Return (ingress-only / DSR)
Section titled “Magic Transit Direct Server Return (ingress-only / DSR)”With asymmetric routing, Internet ingress enters Cloudflare and GRE (MTU 1,476), while datacenter egress may use DSR at MTU 1,500. You must still shrink TCP segments for traffic from the Internet toward your prefix.
For Magic Transit ingress-only traffic (DSR):
- On edge router transit ports: TCP MSS clamp maximum 1,436 bytes.
- On third-party IPsec/GRE tunnels on your Magic Transit prefix: on the internal tunnel interface (often a firewall behind the GRE terminator), reduce the current MSS clamp by 24 bytes (GRE overlay) or 140 bytes (IPsec overlay).
Key takeaway from the preceding chart: MSS clamping affects TCP packet payload sizes flowing in the opposite direction versus where the clamp is applied.
— Cloudflare, Maximum transmission unit and maximum segment size (Magic Transit)
Tunnel-in-tunnel and third-party VPN on your prefix
Section titled “Tunnel-in-tunnel and third-party VPN on your prefix”If Magic Transit GRE carries another IPsec or GRE tunnel on your premises, MSS clamp on the outer tunnel does not fix inner encapsulated IP. Lower the MTU of the internal tunnel interface for both ingress and egress. For third-party tunnels, Cloudflare troubleshooting suggests ~1,300 bytes MSS on the firewall IPsec internal interface facing the Magic Transit prefix when inbound packets traverse GRE (MTU 1,476)—see Troubleshooting connectivity issues after prefix advertisement.
AWS Site-to-Site VPN and Path MTU Discovery limits
Section titled “AWS Site-to-Site VPN and Path MTU Discovery limits”AWS Site-to-Site VPN does not expose per-VPN MSS clamping and does not support Path MTU Discovery. Do not rely on PMTUD on that path.
AWS Site-to-Site VPN does not support Path MTU Discovery. Validate large TCP flows with controlled packet-size and Don’t Fragment (DF) tests.
— Cloudflare, Amazon AWS Transit Gateway
Apply MSS clamp (≤ 1,360 where architecture allows) on a device or workload in the traffic path. Use controlled packet-size and DF-bit tests to find effective path MTU. Check whether ICMP fragmentation-needed messages are filtered.
Cloudflare Mesh double encapsulation and source MTU
Section titled “Cloudflare Mesh double encapsulation and source MTU”Mesh nodes encapsulate traffic; Mesh-to-Mesh paths may encapsulate twice (sending node, then Cloudflare before delivery). Packets near 1,460 bytes or more can exceed 1,500 after double encapsulation and be dropped.
If source devices send packets near the maximum size (1,460 bytes or more), the double encapsulation can push packets over 1,500 bytes, causing them to be dropped.
— Cloudflare, Best practices (Cloudflare Mesh)
Recommendations: set source device MTU to 1,280 bytes; for TCP-only traffic, MSS clamp 1,240 (1,280 − 20 − 20). Modern apps using PMTUD may adapt—see Troubleshoot Cloudflare Mesh connectivity.
For Magic Transit IPv6, Cloudflare transports IPv6 over IPv6-over-IPv4 GRE (IP protocol 47). With ingress-only (DSR), clamp TCP MSS to maximum 1,416 on edge transit ports for the larger IPv6 header—Configure IPv6.
Fragmentation, DF bit, and incomplete packets at Cloudflare
Section titled “Fragmentation, DF bit, and incomplete packets at Cloudflare”Oversized packets are dropped or fragmented. Cloudflare reassembles before customer delivery when possible:
Cloudflare never sends incomplete packets to customers: If Cloudflare does not see all parts of a packet required to fully reassemble that packet, Cloudflare will not send the partial data fragments to the customer.
— Cloudflare, Maximum transmission unit and maximum segment size
Most TCP stacks set the do not fragment (DF) bit. If you cannot lower MSS on physical interfaces below 1,500, Cloudflare can clear the DF bit so it fragments packets greater than 1,500 bytes for reassembly on your side after decapsulation—last resort; contact your account team (Get started (Magic Transit)). Cloudflare One Client documentation notes minimum 1,281 bytes with PMTUD on client tunnels—see Path MTU Discovery.
Common mistakes when TCP works for small packets only
Section titled “Common mistakes when TCP works for small packets only”| Symptom | Likely cause | What documentation recommends |
|---|---|---|
| HTTPS/HTTP on 80/443 fails; small probes work | MSS clamp missing or wrong on all CPE egress ports | Clamp on every egress interface; capture SYN/SYN-ACK MSS both ends |
| Internet cannot reach TCP service on advertised prefix | Same; DSR path not clamped on transit ports | 1,436 on transit ports for ingress-only Magic Transit |
| Large Mesh transfers stall | Double encapsulation MTU | Source MTU 1,280, MSS 1,240 for TCP |
| AWS VPN large flows fail | No PMTUD on AWS VPN | DF tests; clamp ≤ 1,360 on-path |
| Nested IPsec/GRE on Magic Transit prefix | MSS clamp does not affect outer encapsulation | Lower internal tunnel MTU; reduce nested MSS by 24 or 140 bytes |
Packets exceeding the tunnel MTU are fragmented or dropped, causing intermittent connectivity issues.
— Cloudflare, Troubleshoot IPsec tunnels
Temporary test: lower MSS on a LAN interface of a host inside the prefix; if behavior improves, tune production clamps on all edge egress paths—Troubleshooting connectivity issues after prefix advertisement.
How to check this on your site
Section titled “How to check this on your site”-
Map your topology (GRE, IPsec, DSR, Mesh, nested tunnels) and note target values from Connectivity options and Maximum transmission unit and maximum segment size.
-
Confirm MSS clamps on the correct internal tunnel interfaces and transit ports (GRE 1,436, IPsec ≤ 1,360, nested adjustments −24 or −140 bytes as applicable).
-
Capture TCP handshakes at both ends and verify MSS in SYN/SYN-ACK matches your design; follow Troubleshooting connectivity issues after prefix advertisement.
-
Run controlled large-packet and DF-bit tests (especially on AWS VPN paths); confirm ICMP fragmentation-needed is not blocked—Amazon AWS Transit Gateway.
-
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.