Troubleshooting Path MTU Discovery: When Packets Mysteriously Vanish
AI generated
$
/etc
Linux
Troubleshooting Path MTU Discovery
When packets mysteriously vanish

SSH connections that establish normally but freeze on the first larger output, or HTTPS pages that only partially load, rarely point to an application bug and almost always point to blocked Path MTU Discovery. Understanding how PMTUD works and where it typically breaks turns these hard to pin down network faults into a diagnosis of minutes instead of hours.

10 min read Linux Networking Troubleshooting

1. What Path MTU Discovery actually solves

Every network link along a path can support a different maximum packet size, the Maximum Transmission Unit. While local Ethernet segments typically allow 1500 bytes, tunneling technologies such as VPNs, GRE, or PPPoE regularly reduce the usable size through additional protocol overhead, often down to values between 1400 and 1480 bytes. Without a mechanism that recognizes these differences, routers would either silently fragment packets or, worse, simply drop larger ones.

Path MTU Discovery solves this by having the sender transmit packets with the Don't Fragment bit set, explicitly forbidding routers from splitting the packet into smaller fragments if needed. When a router along the path encounters a packet larger than the next hop's MTU, it drops it and sends an ICMP type 3, code 4, Fragmentation Needed message back to the sender, which also carries the actual supported MTU of the affected hop. The sender then reduces the packet size for that connection and retries the transfer.

2. Why blocked ICMP messages become the real problem

In practice, many firewalls configure blanket rules that drop all ICMP traffic, often based on an outdated security mindset that treats ICMP as inherently dangerous. Those very rules also block the Fragmentation Needed message that Path MTU Discovery depends on, which means the sender never finds out its packet was dropped and keeps sending packets at the original, too large size.

This behavior is known as black hole PMTUD, because packets above the actual path MTU literally vanish somewhere on the network without any feedback reaching the sender or application. Since smaller packets, such as the initial TCP handshake or short SSH control messages, do not trigger the issue, the connection appears to work fine at first, right up until the application tries to send its first larger packet, which then gets silently dropped and effectively freezes the connection.

3. Typical symptoms: hanging SSH sessions and truncated HTTP responses

A classic symptom is an SSH connection that establishes without issue and works fine for simple commands like ls, but freezes completely as soon as a command with large output, such as cat on a bigger file, or an interactive program with a full terminal redraw, is run. The SSH handshake itself consists of many small packets below the problematic size threshold, while the actual data transfer is the first thing to generate packets at full MTU size.

At the HTTP and HTTPS level, the same problem shows up as pages that only partially load, TLS handshakes that complete successfully but then hang, or API responses that work fine with small JSON payloads but consistently time out on larger ones. What makes this particularly tricky is that the behavior often only appears for certain destination or source networks, while other connections through the same server work completely fine, because only specific path segments actually have a reduced MTU.

4. Diagnosis step one: finding the actual path MTU with ping

The most reliable first diagnostic step is a targeted ping with the Don't Fragment bit explicitly set and a variable packet size, iteratively narrowing down the largest packet size that still works. On Linux, the Don't Fragment bit is set via the -M do option, while -s defines the payload size excluding the 28 byte IP and ICMP header, which is why for a target MTU of 1500 bytes the largest working -s value is 1472.

If a ping with a given size fails while smaller sizes succeed, a binary search between the two values quickly narrows down the actual path MTU. If no error appears at all and packets simply vanish without any response, that is already a strong sign the necessary ICMP feedback is being blocked somewhere along the path, rather than there being no MTU restriction at all.


# Test whether a payload of 1472 bytes (1500 MTU) makes it through
ping -M do -s 1472 -c 3 target-server.example.com

# On failure, step down through smaller sizes until the actual
# path MTU is found
ping -M do -s 1400 -c 3 target-server.example.com

5. Diagnosis step two: tracepath for automated MTU discovery

Instead of manually bisecting the correct packet size, tracepath automates exactly that process while simultaneously identifying at which hop along the path the MTU actually gets reduced. The tool sends packets with increasing TTL, similar to traceroute, but combines this with Path MTU Discovery and explicitly shows in its output where the allowed packet size first shrinks.

If the tracepath output stops at a certain hop with no further pmtu messages, that points to an ICMP block right at that location, where the necessary Fragmentation Needed message is either not generated by the affected router at all, or dropped by a firewall on the way back. This information is especially valuable when several network segments are involved, for example a VPN link between two data centers, since it narrows down whether the problem sits at your own edge router or further upstream at the provider.


# Automatically determine the path MTU and the hop where it shrinks
tracepath target-server.example.com

# Example output with one hop that reduces the MTU to 1420
#  3:  vpn-gateway.example.net       1.2ms pmtu 1420
#  4:  no reply

6. Diagnosis step three: watching ICMP traffic directly with tcpdump

To confirm beyond doubt whether an ICMP Fragmentation Needed message ever reaches the original sender at all, a targeted tcpdump capture session on the affected server, run alongside a simultaneous large packet test, is invaluable. If no ICMP type 3 code 4 message arrives even though the ping or tracepath test clearly points to an MTU restriction, the fault most likely lies in a local or upstream firewall rule that drops incoming ICMP traffic outright.

Especially in cloud environments and with security groups that by default only open selected ports rather than entire protocols, a missing ICMP allowance is one of the most common causes of PMTUD problems. The capture makes it visible whether the problem actually sits on your own system or further upstream at the provider, which speeds up troubleshooting considerably instead of changing configuration in several places on a hunch.


# Capture incoming ICMP traffic on the server
tcpdump -ni eth0 icmp

# In a second terminal, trigger a large packet test during the capture
# to verify whether the Fragmentation Needed reply actually arrives
ping -M do -s 1472 -c 3 target-server.example.com

7. TCP MTU probing: PMTUD without depending on ICMP

In response to widespread ICMP blocking across the public internet, RFC 4821 defines Packetization Layer Path MTU Discovery, a mechanism that determines the actually usable packet size directly at the TCP layer without relying on incoming ICMP messages at all. Instead of waiting for a Fragmentation Needed reply, the TCP stack experimentally sends larger packets and checks whether an acknowledgment for them arrives, so missing ICMP feedback no longer causes a black hole, but is simply interpreted as a missing acknowledgment.

On Linux, this behavior can be enabled via the kernel parameter net.ipv4.tcp_mtu_probing, where a value of 1 enables probing only after a black hole has been detected, and a value of 2 forces probing by default for all TCP connections. For servers that regularly talk to networks whose ICMP configuration cannot be controlled, for example connections to customer networks or third party APIs, enabling TCP MTU probing is a valuable addition to MSS clamping and allowing ICMP, since it catches the problem even when neither of the other two measures can be enforced for organizational reasons.


# Enable TCP MTU probing permanently, value 1 = only after a detected
# black hole, value 2 = always active for all TCP connections
sysctl -w net.ipv4.tcp_mtu_probing=1

# Persist it in the sysctl configuration
echo "net.ipv4.tcp_mtu_probing = 1" >> /etc/sysctl.d/99-pmtud.conf
sysctl --system

8. Fix one: allow ICMP Fragmentation Needed deliberately instead of blanket blocking

The cleanest and most durable fix is to stop blocking ICMP outright and instead deliberately allow the message types Path MTU Discovery needs, while still restricting other ICMP types as desired. For IPv4, that specifically means ICMP type 3 code 4, and for IPv6 the structurally equivalent ICMPv6 type 2, Packet Too Big, which is even more essential, since IPv6 routers never fragment packets in transit at all and rely entirely on working PMTUD.

A correspondingly precise firewall rule can be implemented with classic iptables just as well as with the more modern nftables framework, and it should be a fixed part of every production server firewall, regardless of how restrictive the rest of the ICMP policy is otherwise.


# Allow ICMP Fragmentation Needed deliberately for IPv4
iptables -A INPUT -p icmp --icmp-type fragmentation-needed -j ACCEPT

# Equivalent for IPv6: allow Packet Too Big
ip6tables -A INPUT -p ipv6-icmp --icmpv6-type packet-too-big -j ACCEPT

9. Fix two: MSS clamping as a robust alternative on gateways and tunnels

Where blocked ICMP messages cannot be reliably fixed, for example because they get dropped by an upstream provider you have no control over, MSS clamping helps by avoiding the problem at the source instead of relying on working PMTUD at all. The technique adjusts the TCP Maximum Segment Size directly within the SYN packet during connection setup, so the resulting packets stay below the actual path MTU from the start.

Especially on VPN gateways and tunnel endpoints, where added protocol overhead regularly reduces the effective MTU, MSS clamping is the more pragmatic and robust solution compared to relying solely on ICMP based PMTUD, since it works independently of firewall configuration along the rest of the path and structurally prevents the problem instead of merely detecting it.


# MSS clamping on a VPN gateway for outgoing traffic over tun0
iptables -t mangle -A FORWARD -o tun0 -p tcp --tcp-flags SYN,RST SYN \
  -j TCPMSS --clamp-mss-to-pmtu

# Equivalent in nftables syntax
nft add rule inet mangle forward oifname tun0 tcp flags syn tcp option \
  maxseg size set rt mtu
Symptom Likely cause Diagnostic tool Recommended fix
SSH hangs on large output Blocked ICMP Fragmentation Needed message ping -M do with variable size Deliberately allow ICMP type 3 code 4
HTTPS page loads only partially Black hole PMTUD between client and server tracepath and tcpdump Enable MSS clamping on the gateway
VPN tunnel only works for small packets Reduced effective MTU due to tunnel overhead tracepath across the tunnel MSS clamping directly on the tunnel interface
API responses with large payloads time out ICMPv6 Packet Too Big gets dropped tcpdump on ICMPv6 traffic Allow ICMPv6 type 2 at the firewall

Mironsoft

Server administration, Docker hosts, and performance tuning

Linux servers nobody on the team really understands anymore?

We handle setup, hardening, and performance tuning of Linux servers and Docker hosts for Magento deployments, documented and traceable instead of grown and unclear.

Server Audit

Review the existing server configuration for security gaps and performance bottlenecks.

Docker Host Setup

Set up and secure production-ready Docker environments for Magento cleanly.

Monitoring & Tuning

Measure resource usage and tune systemd, kernel, and services with purpose.

10. Summary

PMTUD Troubleshooting

Root cause

Blocked ICMP Fragmentation Needed or Packet Too Big messages

First diagnostic step

ping -M do with variable packet size to narrow down the MTU

Automated diagnosis

tracepath shows the affected hop directly

Most robust fix

MSS clamping on gateways and tunnel interfaces

11. FAQ: PMTUD Troubleshooting

1Why do small requests work but large responses fail?
Small packets stay below the actual path MTU and get delivered without issue, while larger packets hit a router with a smaller MTU and get dropped whenever the associated ICMP feedback is blocked and the sender never reduces packet size.
2Is this problem just as relevant for IPv6 as for IPv4?
It is even more critical, since IPv6 routers are never allowed to fragment packets in transit and rely entirely on working Path MTU Discovery, which means blocked ICMPv6 Packet Too Big messages have even more severe consequences there.
3Is it enough to simply allow all ICMP to avoid the problem?
Yes, that reliably solves the problem, but it is often unnecessarily broad from a security standpoint. It is better to deliberately allow only the ICMP types relevant to PMTUD while still restricting other types.
4What is the difference between adjusting MTU and MSS clamping?
MTU adjustment changes the maximum packet size at the interface level for all traffic, while MSS clamping specifically adjusts only the TCP segment size during connection setup, making it more selective and often more practical.
5Why does the problem often only show up with certain target servers?
Because only specific path segments actually carry a reduced MTU, for example through a VPN tunnel or PPPoE link along the path to that one destination, while other connections run over consistently sized MTUs throughout.
6Can I just disable PMTUD entirely to work around the problem?
Technically possible via the kernel option net.ipv4.ip_no_pmtu_disc, but that then forces fragmentation in the network, which carries its own performance cost and does not work at all for IPv6, which is why allowing ICMP or using MSS clamping is preferable.
7How do I find out exactly which hop the problem sits at?
tracepath explicitly shows in its output where the pmtu value changes or at which point no further response arrives, narrowing down the affected network segment.
8Does MSS clamping also affect UDP based applications?
No, MSS is a purely TCP concept. For UDP based protocols such as some VPN implementations, the application itself must support PMTUD or the MTU of the relevant tunnel interface must be adjusted manually.
9Why isn't a plain ping without -M do sufficient as a test?
Without the Don't Fragment bit, a normal ping allows the kernel or routers to fragment the packet if needed, making the test appear to succeed even though the actual PMTUD problem for non fragmentable TCP connections is still present.
10Should MSS clamping be active by default on every VPN gateway?
Yes, since tunnel overhead practically always reduces the effective MTU, MSS clamping on VPN gateways is a sensible preventive measure that works reliably regardless of the ICMP configuration along the rest of the path.