docs(readme): clarify the MTU calculation is on the link MTU, not interface MTU

This commit is contained in:
Datong Sun 2025-08-23 00:32:24 +08:00 committed by GitHub
parent d8dd3e65d1
commit 141c3477f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -276,22 +276,30 @@ For people who use Phantun to tunnel [WireGuard®](https://www.wireguard.com) UD
out the correct MTU to use for your WireGuard interface.
```
WireGuard MTU = Interface MTU - IPv4 header (20 bytes) - TCP header (20 bytes) - WireGuard overhead (32 bytes)
WireGuard MTU = Link MTU - IPv4 header (20 bytes) - TCP header (20 bytes) - WireGuard overhead (32 bytes)
```
or
```
WireGuard MTU = Interface MTU - IPv6 header (40 bytes) - TCP header (20 bytes) - WireGuard overhead (32 bytes)
WireGuard MTU = Link MTU - IPv6 header (40 bytes) - TCP header (20 bytes) - WireGuard overhead (32 bytes)
```
For example, for a Ethernet interface with 1500 bytes MTU, the WireGuard interface MTU should be set as:
For example, for a network link with 1500 bytes MTU, the WireGuard interface MTU should be set as:
IPv4: `1500 - 20 - 20 - 32 = 1428 bytes`
IPv6: `1500 - 40 - 20 - 32 = 1408 bytes`
**IPv4:** `1500 (link MTU) - 20 - 20 - 32 = 1428 bytes`
**IPv6:** `1500 (link MTU) - 40 - 20 - 32 = 1408 bytes`
The resulted Phantun TCP data packet will be 1500 bytes which does not exceed the
interface MTU of 1500. Please note it is strongly recommended to use the same interface
interface MTU of 1500.
Please note **Phantun can not function correctly if
the packet size exceeds that of the link MTU**, as Phantun do not perform any IP-fragmentation
and reassymbly. For the same reason, Phantun always sets the `DF` (Don't Fragment) bit
in the IP header to prevent intermidiate devices performing any fragmentation on the packet.
It is also *strongly recommended* to use the same interface
MTU for both ends of a WireGuard tunnel, or unexpected packet loss may occur and these issues are
generally very hard to troubleshoot.