feat: add configurable MTU support (#1417)

## Summary
- Add `--mtu <size>` CLI option to configure tunnel MTU (valid range:
576-65535)
- Add interactive prompt with user-friendly explanation for
non-technical users
- Write `tun-mtu` to server.conf and client template when custom value
is set
- OpenVPN auto-calculates MSSFIX based on the MTU value (no separate
option needed)

## Use cases
- PPPoE connections (typically need MTU ~1492)
- Mobile/cellular networks with variable MTU
- Networks with connectivity issues due to fragmentation

## Usage
```bash
# CLI mode
./openvpn-install.sh install --mtu 1400

# Interactive mode prompts with explanation:
# "MTU controls the maximum packet size. Lower values can help
#  with connectivity issues on some networks (e.g., PPPoE, mobile)."
```

Close https://github.com/angristan/openvpn-install/pull/1300

Co-authored-by: Fabian Druschke <fdruschke@outlook.com>
This commit is contained in:
Stanislas
2025-12-15 10:53:15 +01:00
committed by GitHub
parent 15ca74639c
commit 8375af5452
3 changed files with 67 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ INSTALL_CMD=(/opt/openvpn-install.sh install)
INSTALL_CMD+=(--endpoint openvpn-server)
INSTALL_CMD+=(--dns unbound)
INSTALL_CMD+=(--subnet "$VPN_SUBNET")
INSTALL_CMD+=(--mtu 1400)
INSTALL_CMD+=(--client testclient)
# Add TLS signature mode if non-default
@@ -189,6 +190,32 @@ fi
echo "=== systemd service configuration verified ==="
echo ""
# =====================================================
# Verify MTU configuration
# =====================================================
echo "=== Verifying MTU configuration ==="
# Verify MTU in server config
if grep -q "tun-mtu 1400" /etc/openvpn/server/server.conf; then
echo "PASS: Server config has tun-mtu 1400"
else
echo "FAIL: Server config missing tun-mtu 1400"
grep "tun-mtu" /etc/openvpn/server/server.conf || echo "No tun-mtu directive found"
exit 1
fi
# Verify MTU in client template
if grep -q "tun-mtu 1400" /etc/openvpn/server/client-template.txt; then
echo "PASS: Client template has tun-mtu 1400"
else
echo "FAIL: Client template missing tun-mtu 1400"
grep "tun-mtu" /etc/openvpn/server/client-template.txt || echo "No tun-mtu directive found"
exit 1
fi
echo "=== MTU configuration verified ==="
echo ""
echo "Server config:"
cat /etc/openvpn/server/server.conf