Guides

WireGuard MTU problems: connected, but pages hang

If a WireGuard tunnel connects and answers small pings, but HTTPS pages and large downloads hang, some link on the path can't carry the tunnel's largest packets. WireGuard adds 60 bytes over IPv4 and 80 over IPv6, and its usual default of 1420 assumes a clean 1500-byte path all the way. Measure the real path with ping and the don't-fragment flag, set MTU in the config to the path minus 80, and clamp TCP MSS on the server for clients whose configs you can't change.

Tahir Mehmood11 min read

MTU problems are the ones where every quick test passes. The handshake completes, ping works, DNS resolves, and the user still says "nothing loads". This post is about that case: why it happens with WireGuard, how to measure the number you actually need, and the two fixes, a smaller MTU or MSS clamping, with when to use each.

What does a WireGuard MTU problem look like?

Small packets get through and large ones vanish. In practice:

  • wg show has a fresh latest handshake and the transfer counters grow.
  • ping 10.0.0.1 works, and so does a ping to any internet address through the tunnel.
  • curl https://... connects, then hangs during or right after the TLS handshake. The server's certificate is large; the client's first packets are not.
  • SSH logs in, then freezes when a command prints a lot.
  • Some sites load and others don't. A speed test starts and stalls at zero.
  • The same config works on a phone and fails on a laptop, or works at home and fails at a customer's site.

If nothing at all works through the tunnel, not even a small ping to the internet, it is not MTU. Look at forwarding, NAT, DNS and AllowedIPs instead. And if the handshake never completes, MTU is almost never the reason: the handshake packets are 148 and 92 bytes. The handshake checklist covers that case.

Where does WireGuard's 1420 default come from?

1420 is 1500 minus the largest WireGuard overhead, which is 80 bytes. Each data packet gets wrapped like this:

Part Outer IPv4 Outer IPv6
Outer IP header 20 40
UDP header 8 8
WireGuard header (type, receiver index, counter) 16 16
Poly1305 authentication tag 16 16
Total overhead 60 80

The Linux kernel sets a new WireGuard interface to 1500 minus 80, so that the packets fit over either IP version. wg-quick does its own calculation when you don't set MTU. The wg-quick(8) man page says it is "automatically determined from the endpoint addresses or the system default route". In the script, that means: take the MTU of the route to each peer's endpoint, fall back to the default route, fall back to 1500, then subtract 80. On a normal 1500-byte link you get 1420.

WireGuard also pads each packet's plaintext to a multiple of 16 bytes, but never past the interface MTU, so the padding can't push a packet over the limit.

The official apps choose differently when the config has no MTU line, and this explains many "works on one device" reports:

Client MTU when the config doesn't set one
Linux, wg-quick Route MTU to the endpoint minus 80 (1420 on a 1500 link)
Android app 1280
iOS app 1280
macOS app System decides, with 80 bytes of tunnel overhead
Windows app Default route MTU minus 80, updated when the route changes

A phone at 1280 has 140 bytes of headroom that a Linux laptop at 1420 doesn't have. If a config works on the phone and not on the laptop, the laptop's MTU is the first suspect.

Why do big packets disappear instead of being fragmented?

Because the information that they are too big never reaches the program that sent them. Follow one download packet:

  1. A web server sends a full-size TCP segment to the client. The client advertised an MSS that matches its tunnel MTU, so the inner packet is 1420 bytes.
  2. The WireGuard server wraps it. The outer packet is now 1480 bytes (IPv4) or 1500 bytes (IPv6).
  3. Somewhere between the server and the client is a link with a smaller MTU, for example a PPPoE line at 1492. The packet doesn't fit.

What happens next depends on the outer IP version. The Linux WireGuard module sends outer IPv4 packets without the don't-fragment bit, so a router may fragment them. That works on clean paths, but many firewalls, NAT devices and mobile networks drop UDP fragments. IPv6 routers never fragment (RFC 8200); they drop the packet and send an ICMPv6 "Packet Too Big" back, which filters often block.

Either way, the web server never hears about it. Any ICMP error goes to the WireGuard server, which is the sender of the outer packet, and WireGuard does not pass it back into the tunnel. The inner TCP connection keeps resending the same 1420-byte segment until it times out. The TCP handshake and the small packets at the start of the connection fit, so the connection opens and then hangs. That is the signature.

How do I find the right MTU for my WireGuard tunnel?

Measure the path between the two WireGuard endpoints, outside the tunnel, then subtract the overhead.

Step 1: find the path MTU. With the tunnel down (a full tunnel would carry the ping itself), ping the server's public address from the client with fragmentation forbidden. The ICMP payload size plus 28 bytes (20 IP, 8 ICMP) is the packet size, so 1472 tests a 1500-byte path:

$ ping -M do -s 1472 -c 3 176.61.144.20     # Linux
$ ping -D -s 1472 -c 3 176.61.144.20        # macOS
> ping -f -l 1472 176.61.144.20             # Windows

If a router on the path reports the problem, Linux prints a line such as Frag needed and DF set (mtu = 1492), which gives you the number directly. If the packet is larger than your own interface allows, you get local error: message too long, mtu=1500. If the replies simply stop, lower the size in steps of 8 or 10 until they come back. For an IPv6 endpoint, use ping -6 -M do -s 1452 (40-byte header instead of 20). tracepath -n 176.61.144.20 shows the same discovery hop by hop, when the routers send ICMP.

Run it in both directions if you can. Some paths are asymmetric, and the direction that matters most is server to client, because downloads carry the large packets.

Step 2: subtract the overhead. Tunnel MTU = path MTU minus 80. You can use 60 if the endpoints talk over IPv4 only, but 80 is the safe choice and costs 20 bytes per packet.

Step 3: set it on both sides and check through the tunnel.

[Interface]
PrivateKey = <client-private-key>
Address = 10.0.0.2/32
MTU = 1412

Then send a full-size packet through the tunnel to the server's tunnel address. For an inner IPv4 packet, the payload is the MTU minus 28:

$ ping -M do -s 1384 -c 3 10.0.0.1

If that works and the same test with one more byte fails with "message too long", the tunnel MTU is set where you meant it to be. Some numbers for common paths:

Path Path MTU Tunnel MTU (path minus 80)
Ethernet, clean 1500 1420
PPPoE (RFC 2516 limit) 1492 1412
Cloud VM with a 1450 NIC 1450 1370
WireGuard inside another WireGuard 1420 1340

Don't go below 1280 if you route IPv6 inside the tunnel. 1280 is the minimum MTU IPv6 requires, and Linux removes IPv6 from an interface whose MTU is set lower.

Automatic detection can't do this for you, because wg-quick only knows its own side. A server whose NIC is 1450 sets itself to 1370, while a client on a 1500 link sets itself to 1420 and sends packets the server's link can't take. The MTU has to fit the smallest link on the whole path, and only a measurement shows that.

When should I use MSS clamping instead of a lower MTU?

When you can't change the clients. A VPN provider with thousands of configs already handed out, or with MTU = 1420 hardcoded in every one, can fix TCP on the server alone. MSS clamping rewrites the maximum segment size option in TCP SYN packets that the server forwards, so both ends of each connection agree to send smaller segments.

There is a trap here. The common one-liner, tcp option maxseg size set rt mtu (the nftables wiki notes it is the same as iptables' --clamp-mss-to-pmtu), uses the MTU of the route towards the packet's destination. For a SYN from your client to a website, that route is your server's 1500-byte uplink, so the rule changes nothing in exactly the direction that carries downloads. For SYNs coming in from the tunnel, use a fixed value:

table inet wg_mss {
  chain forward {
    type filter hook forward priority mangle; policy accept;
    # SYNs from clients to the internet: this decides download size
    iifname "wg0" tcp flags syn tcp option maxseg size set 1320
    # SYN/ACKs going back into the tunnel: uses wg0's own MTU
    oifname "wg0" tcp flags syn tcp option maxseg size set rt mtu
  }
}

Load it with nft -f wg-mss.nft. The fixed value is the tunnel MTU you need minus 40 for IPv4 or minus 60 for IPv6. One inet table handles both families, so use the IPv6 figure: 1320 fits a 1380 tunnel MTU. The kernel never raises an MSS that is already smaller, so clients with a low MTU of their own keep their value.

The iptables version, for servers that still use it:

iptables -t mangle -A FORWARD -i wg0 -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1340
iptables -t mangle -A FORWARD -o wg0 -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

(1340 here because iptables is IPv4 only; repeat with ip6tables and 1320 for IPv6.) In a wg-quick config you can put these in PostUp and PreDown, using %i for the interface name.

Clamping only fixes TCP. UDP traffic, such as QUIC in browsers, large DNS answers, games and calls, still sends full-size packets. QUIC usually finds a working size by itself, but the rest don't. So clamping is a repair for configs already in the field. For new configs, set the right MTU.

What about PPPoE, mobile networks and tunnels inside tunnels?

These are the three places I look first when a report says "only some users".

  • PPPoE. Many home DSL and fibre lines use it, with an MTU of 1492. A tunnel MTU of 1412 works on them. Clients behind a home router don't see it: the router does PPPoE, the client's own link is a normal 1500-byte one, and automatic detection picks 1420.
  • Mobile networks. Carrier MTUs vary and some are below 1500. The official Android and iOS apps default to 1280 when the config has no MTU line, which is why phones rarely have this problem, unless your config sets MTU = 1420 explicitly. If you hand out one config to every device, leave MTU out for phones or set it low.
  • Nested tunnels. WireGuard over another VPN, through a cloud overlay network, or a double hop (client to entry server to exit server) loses the overhead once per layer. Two WireGuard layers on a 1500 path leave 1340 for the inner one.

How does AmneziaWG change the MTU math?

AmneziaWG adds bytes that plain WireGuard doesn't have, and awg-quick does not account for all of them. Its automatic MTU is the same route MTU minus 80.

  • S4 is a random prefix added to every data packet. On a 1500-byte path with S4 = 20, the auto value of 1420 produces 1520-byte packets over IPv6. Set MTU to the path MTU minus 80 minus S4 yourself; here that is 1400.
  • Jmax is the size of the largest junk packet. The amneziawg-go README warns that if Jmax reaches the system MTU, the junk packets get fragmented, which looks suspicious to DPI. The recommended value of 80 is far from that limit.
  • I1 to I5 decoy packets have whatever size their definition produces. Keep them under the path MTU for the same reason.
  • ContentPaddingAddition and RandomTrailers (3.0 and 3.1) stay inside the interface MTU, according to the Amnezia docs, so they don't change the outer math beyond what you set.

The AmneziaWG parameters post explains each of these settings.

How do I check MTU on a running server?

A few commands show what is configured and what the kernel has learned:

# ip link show wg0                  # the tunnel MTU in use
# ip route get 176.61.144.77        # a learned path MTU shows as "mtu 1400" in the cache line
# tcpdump -ni eth0 'host 176.61.144.77 and ip[6:2] & 0x3fff != 0'

The last one shows IPv4 fragments to and from one client. Seeing them means the outer packets are bigger than some link on the path allows, and they only arrive because they are being fragmented. Fragments make the problem intermittent, because they work on some networks and not on others.

How do I monitor for MTU problems?

A handshake check alone won't catch them. The handshake packets are small, keepalives are small, and a ping is small, so all three pass while users can't load a page. You need a check that pulls a response of real size through the tunnel and has a timeout:

$ curl -m 10 -o /dev/null -s -w '%{http_code} %{size_download}\n' https://www.wireguard.com/

A timeout here, while small pings through the same tunnel work, is the MTU signature.

Full disclosure: a TunnelHQ check brings the tunnel up from your config and then sends real requests to well-known sites through it. If the server's own path has an MTU problem, those requests can stall, and the check reports "Tunnel established - Internet is stuck". Its limits are honest ones: the checks run from TunnelHQ's checkers, not from your users' PPPoE lines or mobile carriers, so a problem that exists only on a user's path won't show up there. For that, the ping test above, run on the user's network, is still the tool.