feat: add custom MTU option to OpenVPN setup #1300
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background / Rationale:
Implemented Changes:
Installation Wizard (
installQuestions()
):Do you want to set a custom MTU for the VPN interface? 1) No, keep default 2) Yes, specify a custom MTU
CUSTOM_MTU
("y" or "n")MTU
(numeric user input if applicable)Server configuration (
installOpenVPN()
):CUSTOM_MTU=="y"
, the script automatically appends to/etc/openvpn/server.conf
:tun-mtu <MTU> mssfix <MTU - 40>
mssfix
setting dynamically adjusts TCP packet sizes to account for VPN overhead (typically IP + TCP/UDP headers of ~40 bytes). This prevents fragmentation and improves throughput and stability.Client Template (
client-template.txt
):.ovpn
configuration file includes:tun-mtu <MTU> mssfix <MTU - 40>
Benefits of this Feature:
Reduced Packet Fragmentation: By precisely matching MTU settings to actual network conditions, fragmentation-related performance issues (delays, retransmissions, and reduced throughput) are mitigated or entirely eliminated.
Enhanced TCP Throughput: The automatic inclusion of
mssfix
optimizes TCP segment sizes, significantly improving overall VPN performance for TCP connections.Greater Network Compatibility: Facilitates optimal operation in scenarios involving nested VPN setups (e.g., OpenVPN within WireGuard or IPsec tunnels), cellular network connections, or specific ISP-imposed MTU constraints.
Simplified Configuration Management: Custom MTU and MSS settings applied consistently across server and client configurations reduce administrative overhead and potential configuration errors.