You are here

MTU Settings for WireGuard Tunnels

3 posts / 0 new
Last post
aa7cl
MTU Settings for WireGuard Tunnels
Having connectivity issues with a client over a WG tunnel. I found the connection stabilized by lowering the MTU on the client's WG interface using the IP link set command. Is there a way to configure MTU for all WireGuard tunnels that is persistent across reboots? 

I have already attempted to set this in the rc.local file:

#!/bin/sh
ip link set dev wgs0 mtu 1350

And, made the rc.local file executable but that didn't work.

Any ideas?

Thanks,

Jim - AA7CL
nc8q
nc8q's picture
ip link set dev wgs0 mtu 1350
Hi, Jim:

Maybe the startup environment is not the same as the root login environment.
Maybe try to invoke ip with a full path:
#!/bin/sh
/sbin/ip link set dev wgs0 mtu 1350

?
Chuck

 
aa7cl
MTU issue WG tunnels
Hi Chuck,
Thanks for your reply.

Due to the fact WG tunnels are dynamically created, and are not always up when rc.local scripts run, I went with creating a hotplug script in:

/etc/hotplug.d/iface/90-wg-mtu

inserted this code:

#!/bin/sh

# Only act on interface-up events
[ "$ACTION" = "ifup" ] || exit 0

# Only apply to WireGuard interfaces (wgs0, wg0, wg1, etc.)
case "$INTERFACE" in
  wg*|wgs*)
    logger -t wg-mtu "Setting MTU on $INTERFACE to 1350"

    # Wait briefly to ensure link is fully ready
    sleep 1

    # Set MTU
    ip link set dev "$INTERFACE" mtu 1350
    ;;
esac

Made it executable:

chmod +x /etc/hotplug.d/iface/90-wg-mtu

Rebooted and all is happy...

Thanks again,

Jim

 

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer