From 2ec929332483d17d17b768ba7d29cf997d89317d Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Thu, 8 Jun 2023 09:50:21 +0000 Subject: [PATCH] feat(wireguard): MTU defaults to 1400 instead of 1420 --- Dockerfile | 2 +- internal/configuration/settings/wireguard.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3c048648..337bd641 100644 --- a/Dockerfile +++ b/Dockerfile @@ -97,7 +97,7 @@ ENV VPN_SERVICE_PROVIDER=pia \ WIREGUARD_PRESHARED_KEY= \ WIREGUARD_PUBLIC_KEY= \ WIREGUARD_ADDRESSES= \ - WIREGUARD_MTU= \ + WIREGUARD_MTU=1400 \ WIREGUARD_IMPLEMENTATION=auto \ # VPN server filtering SERVER_REGIONS= \ diff --git a/internal/configuration/settings/wireguard.go b/internal/configuration/settings/wireguard.go index 49858b0c..e26fd1ed 100644 --- a/internal/configuration/settings/wireguard.go +++ b/internal/configuration/settings/wireguard.go @@ -10,7 +10,6 @@ import ( "github.com/qdm12/gosettings" "github.com/qdm12/gosettings/validate" "github.com/qdm12/gotree" - wireguarddevice "golang.zx2c4.com/wireguard/device" "golang.zx2c4.com/wireguard/wgctrl/wgtypes" ) @@ -32,7 +31,9 @@ type Wireguard struct { Interface string `json:"interface"` // Maximum Transmission Unit (MTU) of the Wireguard interface. // It cannot be zero in the internal state, and defaults to - // the wireguard-go MTU default of 1420. + // 1400. Note it is not the wireguard-go MTU default of 1420 + // because this impacts bandwidth a lot on some VPN providers, + // see https://github.com/qdm12/gluetun/issues/1650. MTU uint16 `json:"mtu"` // Implementation is the Wireguard implementation to use. // It can be "auto", "userspace" or "kernelspace". @@ -150,7 +151,8 @@ func (w *Wireguard) setDefaults(vpnProvider string) { w.Addresses = gosettings.DefaultSlice(w.Addresses, []netip.Prefix{defaultNordVPNPrefix}) } w.Interface = gosettings.DefaultString(w.Interface, "wg0") - w.MTU = gosettings.DefaultNumber(w.MTU, wireguarddevice.DefaultMTU) + const defaultMTU = 1400 + w.MTU = gosettings.DefaultNumber(w.MTU, defaultMTU) w.Implementation = gosettings.DefaultString(w.Implementation, "auto") }