MTU and MSS

When small requests work but large transfers or TLS handshakes hang, a packet size mismatch on the path is the usual cause. Test the largest packet that passes with <code>ping -M do -s</code> or <code>tracepath</code>, lower the MTU on the interface or tunnel that needs it, and clamp TCP MSS in nftables for traffic you forward through a VPN such as WireGuard.

Recovery and troubleshooting guide, updated 2026-12-03

What are MTU, MSS and PMTUD?

MTU (maximum transmission unit) is the largest IP packet an interface sends in one piece. Ethernet uses 1500 bytes by default. MSS (maximum segment size) is the largest TCP payload in one segment; each side announces it in the handshake, normally the MTU minus 40 bytes for IPv4 (20 IP, 20 TCP), so 1460, and minus 60 for IPv6, so 1440.

PMTUD (path MTU discovery) lets a sender learn the smallest MTU on the whole path. Packets go out with the Don't Fragment flag; a router that cannot forward one replies with an ICMP message saying "fragmentation needed" (IPv4) or "packet too big" (IPv6), and the sender shrinks its packets. IPv6 routers never fragment, so on IPv6 PMTUD is not optional.

What does an MTU problem look like?

The giveaway is that size matters:

  • SSH logs in, but cat of a large file or scp freezes after a moment.
  • HTTPS sites hang during the TLS handshake, because the server certificate chain is the first large packet.
  • Small API calls succeed, large uploads or downloads stall without an error.
  • A VPN connects and pings across it, yet web pages through it never finish loading.
  • Problems affect only IPv6 or only traffic through a tunnel.

The cause is almost always a PMTUD black hole: a link with a smaller MTU sits in the path, and the ICMP message that would tell the sender is blocked by a firewall somewhere. Large packets vanish silently and TCP waits.

How do you test the path MTU with ping?

Send pings with the Don't Fragment flag and a chosen payload. For IPv4 the payload is the MTU minus 28 bytes (20 IP, 8 ICMP):

ping -c 3 -M do -s 1472 203.0.113.10    # 1500-byte packets
ping -c 3 -M do -s 1392 203.0.113.10    # 1420-byte packets

If 1472 fails with message too long or simply gets no reply while smaller sizes pass, step down until it works; the largest working payload plus 28 is the path MTU. For IPv6 subtract 48 instead (40 IP, 8 ICMPv6):

ping -6 -c 3 -M do -s 1452 2001:db8:1234:5678::1

On macOS the flag is -D instead of -M do; on Windows use ping -f -l 1472. Test in both directions, from your computer to the server and from the server back.

What does tracepath add?

tracepath walks the path like traceroute and reports where the MTU drops, without needing root:

tracepath -n 203.0.113.10
 1?: [LOCALHOST]                      pmtu 1500
 1:  192.168.1.1                       0.612ms
 2:  198.51.100.1                      7.880ms
 3:  198.51.100.1                      8.020ms pmtu 1420
 ...
     Resume: pmtu 1420 hops 6 back 6

The pmtu value changes where a smaller link starts. Use tracepath -6 for IPv6. If tracepath reports 1500 all the way but large transfers still fail, the ICMP messages are being dropped, which is exactly the black hole case; the fixes below still apply.

Is your own firewall causing it?

Check this first, because it is the one place you control fully. Dropping all ICMP breaks PMTUD for your own server. Allow at least the error types:

# nftables, inside your input chain
ip protocol icmp icmp type { echo-request, destination-unreachable, time-exceeded } accept
ip6 nexthdr icmpv6 icmpv6 type { echo-request, destination-unreachable, packet-too-big, time-exceeded, parameter-problem, nd-neighbor-solicit, nd-neighbor-advert, nd-router-advert } accept

With ufw the default rules already allow these. IPv6 without neighbor discovery and packet-too-big messages does not work properly at all. See the firewall guide for a complete ruleset.

How do you set the MTU of an interface?

Public Ethernet interfaces normally use 1500 bytes; ip link show prints the current value as mtu 1500. You rarely need to change it. When a specific path needs less, or you want to test, set it temporarily first:

ip link show
ip link set dev eth0 mtu 1450

Use the interface name from ip link show; it may be eth0, ens3 or similar. To make it permanent on Ubuntu, add mtu: 1450 under the interface in your netplan file in /etc/netplan/, then apply with netplan try, which rolls back automatically after 120 seconds unless you confirm. If the image manages networking through cloud-init, the generated file may be rewritten; place your change in a separate netplan file with a higher number. On Rocky and Alma use nmcli connection modify "System eth0" 802-3-ethernet.mtu 1450 followed by nmcli connection up "System eth0", with the connection name from nmcli connection show.

Why do VPN tunnels need special care?

A tunnel wraps each packet in another packet. WireGuard adds 60 bytes over IPv4 and 80 over IPv6, so its default interface MTU is 1420: an inner packet of 1420 plus 80 bytes of overhead still fits into 1500. If the outer path itself is smaller, for example a home connection over PPPoE with 1492, lower the tunnel further: set MTU = 1412 or even 1380 in the [Interface] section of /etc/wireguard/wg0.conf on both ends and restart with systemctl restart wg-quick@wg0.

When the server forwards traffic for VPN clients to the internet, clients may announce an MSS that is too large for the tunnel. MSS clamping fixes that at the server by rewriting the value in every forwarded TCP handshake.

How do you clamp MSS with nftables?

Add a rule to the forward chain that sets the MSS of SYN packets to fit the route MTU:

table inet mangle {
  chain forward {
    type filter hook forward priority mangle; policy accept;
    tcp flags syn tcp option maxseg size set rt mtu
  }
}

Save it in /etc/nftables.conf (or a file it includes), check with nft -c -f /etc/nftables.conf, and load with systemctl reload nftables. rt mtu derives the value from the MTU of the outgoing route, which adapts automatically to the tunnel. To set a fixed value instead, use tcp option maxseg size set 1360. Clamping applies only to TCP; for UDP-based protocols such as QUIC, the right MTU on the tunnel interface is the fix. The WireGuard image and the VPN use case show the rest of a tunnel setup.

Questions about this guide

What MTU does my server use?

Run ip link show and read the mtu value of the public interface; Ethernet interfaces normally use 1500 bytes.

Why does only HTTPS hang?

The certificate chain in the TLS handshake is often the first packet near full size. If those packets vanish, the handshake stalls.

Should I lower the MTU everywhere to be safe?

No. A lower MTU costs a little efficiency on every packet. Fix the specific tunnel or path, and allow ICMP so PMTUD works.

Does MSS clamping help UDP traffic?

No, MSS is a TCP option. For UDP, set a correct MTU on the tunnel interface.

What is the right WireGuard MTU?

1420 works on normal 1500-byte paths. Go to 1412 for PPPoE links and lower if tests with ping -M do through the tunnel still fail.

Can support change the MTU of my server?

The MTU inside your server is your setting. If tests show a smaller MTU on a path near our network, send the ping and tracepath results in a ticket.