Path MTU discovery fixes and improvements (#3109)

- Existing option `WIREGUARD_MTU` , if set, disables PMTUD and is used
- New option `PMTUD_ICMP_ADDRESSES=1.1.1.1,8.8.8.8` and `PMTUD_TCP_ADDRESSES=1.1.1.1:443,8.8.8.8:443`
- ICMP PMTUD now targets external-by-default IP addresses
- New TCP PMTUD (binary search only) as a second MTU confirmation and fallback mechanism.
- Force set TCP MSS to MTU - IP header - TCP base header - "magic 20 bytes" 🎆
- Fix #3108
This commit is contained in:
Quentin McGaw
2026-02-15 01:40:34 +01:00
committed by GitHub
parent 8f1fda7646
commit be92aa2ac4
59 changed files with 2050 additions and 376 deletions
+11 -1
View File
@@ -16,7 +16,17 @@ func BuildWireguardSettings(connection models.Connection,
settings.PreSharedKey = *userSettings.PreSharedKey
settings.InterfaceName = userSettings.Interface
settings.Implementation = userSettings.Implementation
settings.MTU = userSettings.MTU
if *userSettings.MTU > 0 {
settings.MTU = *userSettings.MTU
} else {
// The default is 1320 which is NOT the wireguard-go default
// of 1420 because this impacts bandwidth a lot on some
// VPN providers, see https://github.com/qdm12/gluetun/issues/1650.
// It has been lowered to 1320 following quite a bit of
// investigation in the issue: https://github.com/qdm12/gluetun/issues/2533.
const defaultMTU = 1320
settings.MTU = defaultMTU
}
settings.IPv6 = &ipv6Supported
const rulePriority = 101 // 100 is to receive external connections
+3 -1
View File
@@ -22,7 +22,7 @@ func Test_BuildWireguardSettings(t *testing.T) {
ipv6Supported bool
settings wireguard.Settings
}{
"some settings": {
"some_settings": {
connection: models.Connection{
IP: netip.AddrFrom4([4]byte{1, 2, 3, 4}),
Port: 51821,
@@ -41,6 +41,7 @@ func Test_BuildWireguardSettings(t *testing.T) {
},
PersistentKeepaliveInterval: ptrTo(time.Hour),
Interface: "wg1",
MTU: ptrTo(uint32(1000)),
},
ipv6Supported: false,
settings: wireguard.Settings{
@@ -58,6 +59,7 @@ func Test_BuildWireguardSettings(t *testing.T) {
PersistentKeepaliveInterval: time.Hour,
RulePriority: 101,
IPv6: boolPtr(false),
MTU: 1000,
},
},
}