Skip to content

Conversation

@kvaps
Copy link

@kvaps kvaps commented Feb 10, 2026

Summary

  • Change the --mtu flag default from a fixed 1420 to "auto", which detects the MTU of the underlay network interface and subtracts the WireGuard overhead (80 bytes)
  • Re-detect MTU on each reconciliation loop to handle interface changes
  • The flag still accepts numeric values for manual override

Motivation

In multi-cloud deployments, different locations may have different underlay MTUs (e.g. 1500 on bare metal vs 1400 on Azure). A fixed MTU causes packet fragmentation or drops when the underlay MTU is smaller than expected. Auto-detection eliminates the need for per-node MTU configuration.

Changes

  • pkg/wireguard/wireguard.go: Add WireGuardOverhead constant (80 bytes) and SetMTU() helper
  • pkg/mesh/mesh.go: Add detectMTU() function, mtu/autoMTU fields, MTU re-detection in applyTopology()
  • cmd/kg/main.go: Change --mtu flag from uint to string with "auto" default

Change the --mtu flag default from a fixed 1420 to "auto", which detects
the MTU of the underlay network interface and subtracts the WireGuard
overhead (80 bytes) to calculate the optimal WireGuard interface MTU.

This is particularly useful in multi-cloud deployments where different
locations may have different underlay MTUs (e.g. 1500 on bare metal
vs 1400 on Azure). The MTU is re-detected on each reconciliation loop
to handle interface changes.

The flag still accepts numeric values for manual override.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@kvaps kvaps marked this pull request as ready for review February 10, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant