An SSH session that authenticates and then freezes when a command produces a lot of output is a classic path MTU discovery (PMTUD) failure. Small packets — the TCP handshake, the SSH banner, echo requests — cross the path, but full-sized data segments disappear. The same pattern appears as an HTTPS transfer that completes the TLS handshake and then stalls.
This tutorial shows how to reproduce that failure on a Linux VPN, use tracepath to find where the usable MTU drops, confirm an ICMP black hole with DF pings and tcpdump, and repair it with a tunnel MTU change or TCP MSS clamping. IPv4 is the main example, with a short IPv6 note.
Table of Contents
- 1. Reproduce the Freeze: Small Packets Pass, Large Ones Stall
- 2. Trace the Path and Read the PMTU Changes
- 3. Confirm the Black Hole with DF Pings and tcpdump
- 4. Fix the Tunnel MTU or Clamp TCP MSS
- 5. Verify Recovery and Triage the Result
- Conclusion
1. Reproduce the Freeze: Small Packets Pass, Large Ones Stall
Use a lab or maintenance window, and pick a destination that is reachable through the tunnel. The examples below use a WireGuard-style tunnel from a client at 10.8.0.2 to a gateway at 10.8.0.1, with the gateway’s public address at 198.51.100.10 and a server at 203.0.113.20.
First establish that the problem is size-dependent, not a simple reachability failure:
# Small request: usually succeeds
ssh -o ConnectTimeout=5 admin@203.0.113.20 'echo alive; uname -r'
# Large response: often hangs after authentication
timeout 20 ssh admin@203.0.113.20 'head -c 5000000 /dev/zero | base64' >/dev/null
echo "ssh exit status: $?"
An exit status of 124 means timeout killed a session that was still waiting. For HTTPS, the same test often completes the TLS handshake and then stops:
curl -v --max-time 20 -o /dev/null https://203.0.113.20/large.bin
This pattern is exactly what RFC 2923 describes: pings and interactive TCP connections work, but bulk transfers fail when the first large packet is dropped, and the connection eventually times out. Firewalls are often misconfigured to suppress the ICMP messages that would otherwise tell the sender to reduce its packet size.
Next, record the MTUs you are actually working with:
ip -br link show
ip link show dev wg0
ip link show dev eth0
ip route get 203.0.113.20
In the failing example, wg0 reports mtu 1420 while eth0 reports mtu 1500. The wg0 value is the largest inner packet the tunnel interface will accept; it is not a measurement of the underlay path. If the underlay path can only carry 1400-byte packets, a 1420-byte inner packet becomes roughly 1480 bytes on the wire after the outer IP, UDP and tunnel headers are added. That is larger than the underlay can forward.
The repair therefore starts with a simple question: is the tunnel’s configured MTU larger than the underlay path can support?
2. Trace the Path and Read the PMTU Changes
tracepath is useful here because it traces the path and reports the PMTU when it changes. It does not require root privileges, and -n keeps the output numeric so DNS delays do not obscure the result. The -l option sets the initial probe length instead of the default 65535 bytes for IPv4.
Run it from the affected client, through the tunnel, to the destination:
tracepath -n -l 1500 203.0.113.20
A failing trace may look like this:
1?: [LOCALHOST] pmtu 1420
1: 10.8.0.1 1.284ms
2: no reply
Read this carefully:
- The first line shows the local tunnel MTU, 1420.
- Hop 1 is the VPN gateway and it replies.
- Hop 2 produces no reply, which means probes large enough to be encapsulated and sent beyond the gateway are not coming back.
That is consistent with a drop beyond the gateway, but it is not yet proof of an MTU black hole. The probe could also be blocked by a firewall, or the destination could be unreachable for another reason. The next step is to trace the underlay path to the gateway’s public endpoint:
tracepath -n -l 1500 198.51.100.10
A revealing result looks like this:
1?: [LOCALHOST] pmtu 1500
1: 192.0.2.1 2.104ms
1: 192.0.2.1 2.033ms pmtu 1400
2: 198.51.100.10 9.818ms reached
Resume: pmtu 1400 hops 2 back 2
The repeated hop is the important detail. The first probe at 1500 bytes was rejected at that router; tracepath retried at 1400 and got through. The pmtu 1400 field appears only when the path MTU changes, and the final Resume line summarizes the detected PMTU, hop count and return path. The tracepath manual page documents this output format, including the meaning of asymm and the ? that appears when the TTL has to be guessed.
For a broader walkthrough of TTL probing, the -l and -p options, and how to interpret fields such as asymm, see tracepath’s built-in Path MTU discovery.
Two cautions matter when reading the output:
-
tracepathshows the PMTU only when it changes. It is not an MTU readout for every hop. -
tracepathuses UDP probes, so a firewall that blocks those probes can also produceno reply. Confirm the finding with the DF ping sweep in the next section.
For IPv6, use tracepath -6:
tracepath -6 -n -l 1500 2001:db8::20
tracepath -6 is the modern replacement for traceroute6, and the output format is essentially the same. IPv6 PMTUD relies on ICMPv6 Packet Too Big messages rather than the IPv4 DF mechanism. When those messages are blocked, IPv6 connections can complete the TCP handshake and then hang in the same way. RFC 8201 describes this black-hole behavior and the ICMPv6 feedback that PMTUD depends on.
3. Confirm the Black Hole with DF Pings and tcpdump
A DF ping sweep gives you a size boundary. On Linux, ping -M do sets the Don’t Fragment bit and rejects packets that exceed the local PMTU, while -s sets the ICMP payload size. For IPv4, the total IP packet size is:
payload + 8-byte ICMP header + 20-byte IPv4 header
So a 1312-byte payload produces a 1340-byte IP packet, and a 1332-byte payload produces a 1360-byte packet.
Run a sweep from the client through the tunnel:
for s in 1200 1280 1312 1332 1352 1372 1392; do
if ping -M do -s "$s" -c 1 -W 2 203.0.113.20 >/dev/null 2>&1; then
echo "$((s+28))-byte packet: reply"
else
echo "$((s+28))-byte packet: no reply"
fi
done
If 1340-byte packets get replies but 1360-byte packets do not, you have a boundary consistent with an inner path MTU of about 1340. That fits the earlier example: 1360 bytes of inner traffic plus 60 bytes of outer IPv4, UDP and tunnel overhead is 1420 bytes, which exceeds the 1400-byte underlay path.
To confirm the underlay itself, run the same kind of test from the VPN gateway against the peer’s public address:
# 1400-byte IP packet: should pass if the underlay PMTU is 1400
ping -M do -s 1372 -c 1 198.51.100.10
# 1500-byte IP packet: should fail if the underlay PMTU is 1400
ping -M do -s 1472 -c 1 198.51.100.10
If the 1500-byte packet fails with a message such as Frag needed and DF set (mtu = 1400), the router is sending the correct ICMP feedback and the underlay path is telling you its limit. If it simply goes silent, the ICMP message may be filtered, or the router may not be generating it.
Capture ICMP while you run the sweep. On the gateway, capture on the underlay interface or on any:
sudo tcpdump -ni any -vv 'icmp and host 198.51.100.10'
The icmp primitive is standard libpcap filter syntax. In the capture, look for an ICMP unreachable message that reports need to frag and an MTU value. That is the PMTUD feedback path working. If you see the large DF packets leaving but no corresponding ICMP message, you are looking at a silent drop or an ICMP filter.
This distinction is the difference between two similar-looking problems:
- ICMP is delivered: PMTUD has the information it needs, but the sender may be ignoring it, or the message may be filtered later on the return path.
- ICMP is absent: the sender never learns the real path MTU and keeps retrying full-sized packets. That is the black hole.
RFC 2923 recommends exactly this kind of test: small echo packets succeed, MTU-sized echo packets with DF set fail, and the connection stalls while the control channel appears healthy.
4. Fix the Tunnel MTU or Clamp TCP MSS
Fix the underlay mismatch first. If the tunnel MTU is larger than the underlay can carry after encapsulation, MSS clamping alone may not save you, because the route’s PMTU will still be wrong.
Option 1: Lower the tunnel MTU
For the example underlay PMTU of 1400 and roughly 60 bytes of outer IPv4, UDP and WireGuard overhead, the largest safe inner packet is about 1340 bytes:
sudo ip link set dev wg0 mtu 1340
If the outer path may use IPv6, the overhead grows by another 20 bytes, so 1320 is the safer value. Do not go below 1280 if the tunnel carries IPv6, because 1280 is the IPv6 minimum link MTU.
For a persistent WireGuard configuration, set the MTU in the interface section:
[Interface]
Address = 10.8.0.2/24
MTU = 1320
The wg-quick manual documents MTU as the interface setting that overrides automatic MTU discovery.
Lowering the tunnel MTU constrains every protocol carried by the tunnel, including UDP and ICMP. That is its advantage: it is simple and predictable. Its disadvantage is that it reduces payload efficiency for all traffic, even connections that would have negotiated a smaller segment size anyway.
Option 2: Clamp TCP MSS
TCP MSS clamping is more targeted. The MSS is the maximum TCP payload per segment, negotiated during the handshake, and it does not include the TCP and IP headers. A gateway can rewrite the MSS in forwarded SYN packets so that each side advertises a segment size that fits the tunnel.
On an iptables gateway, clamp forwarded TCP handshakes to the route PMTU:
sudo iptables -t mangle -A FORWARD \
-p tcp --tcp-flags SYN,RST SYN \
-j TCPMSS --clamp-mss-to-pmtu
The TCPMSS target with --clamp-mss-to-pmtu sets the MSS to the path MTU minus 40 bytes for IPv4 and minus 60 bytes for IPv6. One FORWARD rule sees both the client’s SYN and the server’s SYN-ACK, so it can clamp both directions.
There are two important caveats:
-
The route PMTU must be correct. If
wg0still reports 1420 but the real underlay limit is 1400,--clamp-mss-to-pmtuwill clamp to 1380 — still too large. Lower the tunnel MTU first, or use an explicit MSS value. -
FORWARDonly covers traffic routed through the gateway. Traffic generated locally on the gateway itself needs anOUTPUTrule instead. On a client that terminates the tunnel locally, the simplest fix is usually the tunnel MTU, because there is no forwarding path to clamp.
For a known tunnel MTU, an explicit MSS is easier to reason about. For a 1340-byte tunnel:
# IPv4: 1340 - 40 = 1300
# IPv6: 1340 - 60 = 1280
sudo iptables -t mangle -A FORWARD \
-p tcp --tcp-flags SYN,RST SYN \
-j TCPMSS --set-mss 1280
The smaller value is safe for a mixed IPv4/IPv6 path; use 1300 if the tunnel is IPv4-only. Avoid setting the MSS much lower than necessary, because it reduces throughput on every TCP connection.
5. Verify Recovery and Triage the Result
Rerun the same tests in the same order. First confirm the interface MTU changed:
ip link show dev wg0
Then rerun tracepath through the tunnel:
tracepath -n -l 1500 203.0.113.20
You want the trace to get past the point where it previously stopped, with no unexplained no reply at the first tunnel hop. If the underlay path is now correctly reflected, the trace should reach the destination, or at least progress beyond the old failure point.
Next, rerun the DF ping at the size that previously failed:
ping -M do -s 1312 -c 3 203.0.113.20
A 1340-byte packet should now get replies. Then repeat the large SSH transfer:
timeout 30 ssh admin@203.0.113.20 'head -c 5000000 /dev/zero | base64' | wc -c
If the transfer completes and the byte count is what you expect, the black hole is closed. For HTTPS, rerun the same curl --max-time command and confirm it finishes instead of stalling after the handshake.
If you used MSS clamping, verify that the advertised MSS actually changed. Capture TCP SYN packets on the tunnel interface:
sudo tcpdump -ni wg0 -vv 'tcp port 22 and tcp[tcpflags] & tcp-syn != 0'
The SYN and SYN-ACK packets should show an MSS value at or below the value you intended. If they still show the old value, check that the rule is in the right table and chain, that the traffic is actually passing through FORWARD, and that another rule is not overriding it.
Use this table to separate the remaining possibilities:
| What you see | What it usually means | Next check |
|---|---|---|
Small pings and SSH login work; large transfers stall; DF pings fail above a size; ICMP need to frag is captured |
MTU mismatch or PMTUD black hole | Lower the tunnel MTU or clamp MSS |
Same stall, but large DF packets leave and no ICMP need to frag is captured |
ICMP is filtered or not generated | Check ICMP type 3 code 4 in both directions; capture on the underlay |
| Small pings also fail, or the tunnel handshake is unstable | Routing or tunnel reachability problem, not MTU | Check ip route get, the WireGuard handshake and the underlay ping |
| Stalls are random; small pings show loss or jitter | Congestion or packet loss, not a clean MTU boundary | Check interface errors, mtr and queueing |
| DF pings pass at all sizes but TCP throughput is still poor | Not an MTU problem | Check TCP window, congestion and application behavior with ss -ti
|
Conclusion
A VPN connection that authenticates but freezes on large output is often not a routing failure. It is frequently a PMTU black hole: the tunnel’s configured MTU is larger than the underlay can carry after encapsulation, and the ICMP feedback that would correct the sender never arrives.
The diagnostic sequence is repeatable. Reproduce the size-dependent failure, record the tunnel and underlay MTUs, run tracepath and read where the reported PMTU changes or where replies stop, then confirm the boundary with a DF ping sweep and tcpdump. Fix the underlay mismatch first by lowering the tunnel MTU, or clamp TCP MSS once the route PMTU is accurate. Finally, rerun tracepath, the DF ping and the original large transfer to prove the path recovered.
Top comments (0)