Skip to content

feat(start-wrt): size outbound VPN MTUs to fit and look up chained VPN hostnames - #4885

Open
gStart9 wants to merge 2 commits into
masterfrom
wrt/vpn-mtu
Open

gStart9 wants to merge 2 commits into
masterfrom
wrt/vpn-mtu

Conversation

@gStart9

@gStart9 gStart9 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Outbound VPNs now get an MTU that fits through what each VPN connects via, a VPN that names its server by hostname can connect via another VPN, and a VPN-routed profile that has no DNS servers anywhere resolves through 1.1.1.1 inside the tunnel.

MTU sized to fit

  • Each outbound VPN uses the largest MTU that fits through what the VPN connects via: the WAN for a VPN that connects via the Internet, or the other VPN's tunnel for a chained VPN.
  • The router recalculates that default whenever the WAN or the VPN that it connects via changes, and the VPN's MTU field shows the default.
  • An MTU in an imported config file is kept only when that MTU is smaller than the default.
  • The router refuses a chain that would push a VPN's MTU below 1280, which is the IPv6 minimum.
  • A new migration, StoreVpnClientMtus, moves existing configs onto the stored-MTU model.

Chained VPNs that name their server by hostname

  • The router looks the hostname up through the tunnel of the VPN that the chained VPN connects via. tunnel_dns binds the lookup to that tunnel's device, so the lookup never leaves through the WAN.
  • The lookup asks the resolvers that a profile routed through that VPN would use (dns::tunnel_dns_servers), and prefers the server's IPv4 address when that tunnel can carry IPv4.
  • A background thread looks the hostname up again when the server stops answering.
  • Diagnostics treat the stored server name as a domain when redacting.

DNS fallback through the tunnel

A profile routed through a VPN that has no DNS servers, and that has none of its own or in WAN Settings, now resolves through 1.1.1.1 inside the tunnel instead of through the ISP's resolvers outside the tunnel. The reasoning is in #2992. dns::fallback_dns_servers holds that fallback, so a configurable fallback list can replace the hard-coded 1.1.1.1 later without migrating stored VPN settings.

SmartDNS speed checks outside the tunnel

SmartDNS's default speed checks ping each address in an answer, and connect to each address on ports 80 and 443, to pick the fastest one. -interface binds only SmartDNS's upstream DNS sockets, so those probes followed the main routing table out through the WAN. The ISP could then see every address that a VPN-routed client looked up. This affected profiles that resolve through a SmartDNS group: profile custom DNS, WAN Settings DNS, and the new 1.1.1.1 fallback. The generated smartdns.conf now sets speed-check-mode none. On the K1 router, a 20-second capture on the WAN during five lookups showed 12 pings before the change and none after.

Interaction with #4882

#4882 moves each VPN's DNS servers from the WireGuard interface to the startwrt.vpn_client section. This PR and #4882 both edit dns.rs, vpn_client.rs, profiles.rs and migrate.rs. Whichever PR merges second needs a rebase that keeps both migrations in merge order at the end of MIGRATIONS. If #4882 merges first, this PR's chained-hostname test must also set the outer VPN's DNS on its vpn_client section instead of calling set_interface_dns. tunnel_dns_servers reads DNS servers only through vpn_dns_servers, so tunnel_dns_servers follows #4882's storage change without edits.

Bench results on a K1 router running 1.4.0 plus this build

  • The pending migrations, including StoreVpnClientMtus, ran on reboot.
  • With the DNS servers of a VPN removed, the profile routed through that VPN resolved through 1.1.1.1 inside the VPN's tunnel, and a capture on the WAN showed no lookups.
  • A VPN that names its server by hostname, chained through a second VPN, looked the hostname up through the second VPN's tunnel with nothing on the WAN, connected, and passed traffic.

🤖 Generated with Claude Code

…N hostnames

Each outbound VPN now uses the largest MTU that fits through what the VPN
connects via: the WAN for a VPN that connects via the Internet, or the
other VPN's tunnel for a chained one. That default is recalculated
whenever the WAN or the VPN that it connects via changes, and the default
is shown in the VPN's MTU field. An MTU in an imported config file is
kept only when that MTU is smaller than the default. The router refuses a
chain that would push a VPN's MTU below 1280. A new migration,
StoreVpnClientMtus, moves existing configs onto the stored-MTU model.

A VPN whose config names its server by hostname can now connect via
another VPN. The router looks the hostname up through the tunnel of the
VPN that it connects via (tunnel_dns binds the lookup to the tunnel's
device), so the lookup never leaves through the WAN. The router asks the
resolvers that a profile routed through that VPN would use, and prefers
the server's IPv4 address when that tunnel can carry one. A background
thread looks the hostname up again when the server stops answering.
Diagnostics treat the stored server name as a domain when redacting.

A profile routed through a VPN that has no DNS servers, and that has none
of its own or in WAN Settings, now resolves through 1.1.1.1 ([reasoning](#2992))
inside the tunnel instead of through the ISP's resolvers outside the
tunnel. dns::fallback_dns_servers holds that fallback, so a configurable
fallback list can replace the hard-coded 1.1.1.1 without migrating stored
VPN settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant