Insights

WireGuard MTU: choose a size, set it and test it

Choose WireGuard MTU for your outer path, set it on Linux and test inner packet sizes without subtracting tunnel overhead twice.

Illustration of unmarked sliding-jaw caliper.
On this page

WireGuard's maximum transmission unit (MTU) sets the largest Internet Protocol (IP) packet your local tunnel interface sends. On a 1500-byte outer path, 1420 bytes leaves room for IPv6 transport, while IPv4-only transport can allow 1440 bytes. Set MTU under [Interface], not [Peer].

In short:

  • Size for the path. Use 1420 bytes for a 1500-byte IPv6 outer path or 1440 for IPv4-only transport.
  • Use the interface. Put your chosen MTU in the tunnel's [Interface] section.
  • Check both ends. WireGuard doesn't negotiate MTU, so check each endpoint and test both directions.

Choose a size that fits the outer path

The outer path carries encrypted WireGuard packets between endpoints. Its IP version determines encapsulation overhead, not the IP version inside the tunnel. WireGuard adds 60 bytes over IPv4 or 80 bytes over IPv6, including User Datagram Protocol (UDP) and WireGuard headers.

These candidates assume the stated outer path limit and no extra encapsulation.

Outer transportOuter pathMTU candidate
IPv4 only1500 bytes1440 bytes
IPv6 or either version1500 bytes1420 bytes
Smaller outer pathKnown lower limitLimit minus applicable overhead

Treat 1420 as a common starting point on a suitable path, not a fixed protocol default. Smaller outer paths need smaller settings. A lower MTU can help clients moving between different networks, but it sends more packets for the same amount of data.

Put the setting on the tunnel interface

These steps apply to Linux with wg-quick. Change only systems you own or administer. Save the original configuration and keep another access route so you can restore it if remote access fails. For a managed client, check which tool owns the configuration and how changes persist before editing.

The stop, edit and start sequence below interrupts the tunnel. Replace wg0 with your actual interface name in the commands and file path.

1. Stop the tunnel with administrative rights.

wg-quick down wg0

2. Update MTU in the existing interface section.

Edit /etc/wireguard/wg0.conf for this example. Update the existing MTU entry, or add it under the existing [Interface] heading if absent. Preserve unrelated settings and don't add a second interface section.

This is a configuration fragment, not a complete configuration. Replace 1420 with your chosen size.

[Interface]
MTU = 1420

3. Bring the tunnel up and check access.

wg-quick up wg0

Check that your peer is reachable again. Restored access shows basic connectivity, not that large packets fit. If access doesn't return, use your recovery route and saved configuration before continuing.

Each endpoint uses its own local interface MTU. Matching settings can simplify administration, but lowering one endpoint doesn't reconfigure the other. MTU applies to the whole tunnel interface, not individual peers. You don't need to lower every local network adapter or switch just to match it.

Test packet size inside the tunnel

On Linux, ping -M do requests no fragmentation, while -s sets the ping payload size. Only probe peers you're authorized to test, and keep your saved configuration available to restore any MTU changes made during testing.

1. Check that the peer answers a small probe.

Replace the clearly marked placeholder with your peer's IPv4 tunnel address. Use an address routed through your tunnel, not its public endpoint address.

PEER_IPV4='REPLACE_WITH_AUTHORIZED_PEER_TUNNEL_IPV4'
ping -M do "$PEER_IPV4"

Replies show that the peer answers these small probes through the tunnel. If it doesn't reply, check reachability and whether the peer accepts ping before testing larger packets. Stop the running probe before continuing.

2. Calculate the candidate and the inner ping payload.

For this hypothetical example, assume a 1500-byte outer path, IPv6 outer transport and no extra encapsulation. Assume an authorized IPv4 tunnel peer answers ping and your local tunnel interface is set to the calculated candidate. Use ordinary IPv4 headers of 20 bytes and Internet Control Message Protocol (ICMP) headers of 8 bytes, with no IP options. ICMP carries ping probes and network error messages.

  • Tunnel MTU candidate: 1500 - 80 = 1420 bytes
  • Inner IPv4 ping payload: 1420 - (20 + 8) = 1392 bytes

The first calculation removes outer encapsulation overhead. The second leaves room for the inner IPv4 and ICMP headers.

3. Send the calculated payload and read the result.

ping -M do -s 1392 "$PEER_IPV4"

If you get replies, 1392 + 28 = 1420 bytes gives the tested inner IP packet size. Don't subtract WireGuard overhead again from that result. Successful replies establish that size for this exchange, not the largest possible size or every destination.

A “message too long” error can reflect your local interface MTU or a known path limit. Reduce the payload and retry after checking the current interface setting. Silence can reflect filtering or packet loss, so a timeout alone doesn't identify an MTU problem.

Your current interface MTU caps this inner probe. It doesn't measure the uncapped outer path MTU or prove that a larger tunnel setting would work.

4. Repeat from the other endpoint and retry the affected task.

Run the same checks from the other end using the first endpoint's IPv4 tunnel address. Then retry the stalled browsing or file transfer. Compare several runs under similar conditions before keeping a changed MTU.

When a smaller MTU doesn't fix the problem

Path MTU discovery (PMTUD) helps senders learn which packet sizes fit by using feedback about oversized packets. At a gateway, check that packet-too-big feedback can reach senders through the firewall. Blocked ICMP feedback can leave senders using packets that don't fit.

Transmission Control Protocol (TCP) uses a maximum segment size (MSS), which limits TCP data per segment instead of the whole IP packet. A scoped MSS-clamping policy at the gateway can lower the size advertised for affected TCP connections. It doesn't fix UDP traffic, so it's not a general replacement for correct interface sizing. Check gateway feedback and policy instead of changing every device behind it.

Smaller isn't always better, and 1280 bytes isn't a guaranteed cure. Browser stalls and closed connections are observations, not proof of an MTU fault. A closed connection also doesn't prove failure during a Transport Layer Security (TLS) handshake.

Where doxx.net fits. doxx.net offers direct device-to-device connections and full, unmodified file transfer. If that's also what you need, create a doxx.net account, download the app and connect a device or agent.

Ask an AI assistant

Share this article

Private Everywhere

Stop giving the internet everything

Keep your browsing, messages, files, and agents private.