From ef953d95219c14dc75c8d5dd3a38e5c651673038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ryan4yin=20=7C=20=E4=BA=8C=E8=8A=B1?= Date: Thu, 15 Oct 2026 00:58:43 +0800 Subject: [PATCH] fix(mihomo): disable gateway IPv6 DNS answers (#443) The gateway LAN IPv6 transparent path stalls on TCP flows while IPv4 forwarding remains healthy. Withholding AAAA answers keeps LAN clients on the working fake-IPv4 TProxy path until the IPv6 path is fixed Assisted-by: DeepSeek Harness (gpt-6.1-sol) --- .../nixos/desktop/networking/mihomo/README.md | 24 ++++++++++--------- .../networking/mihomo/gateway-config.nu | 5 ++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/modules/nixos/desktop/networking/mihomo/README.md b/modules/nixos/desktop/networking/mihomo/README.md index 78306f77..2823453e 100644 --- a/modules/nixos/desktop/networking/mihomo/README.md +++ b/modules/nixos/desktop/networking/mihomo/README.md @@ -63,18 +63,20 @@ still reaches the core. The gateway (`suzi`, not a host in this flake) runs the same config with a fixed set of deltas -- `gateway-config.nu` renders it from the same `sources.yaml` and `policy.yaml`. The gateway uses -nftables TProxy, disables the desktop TUN auto-route, and uses `fake-ip` DNS with `dns.ipv6: true`: -LAN clients receive stable fake A/AAAA mappings so mihomo retains the domain for routing and -sniffing. Its output carries the subscriptions and the private domains, so never commit it; the -secret is filled in on the box, not here. Its binary is a static release build under `/usr/local/bin`, -not a package: update it by hand, validate the live config with the new core (`mihomo -t -d /etc/mihomo --f `) before swapping, and keep the previous binary. The release ships no checksums, so TLS -plus `-v` is the whole verification. +nftables TProxy, disables the desktop TUN auto-route, and uses `fake-ip` DNS with `dns.ipv6: false`: +LAN clients receive fake A mappings so mihomo retains the domain for routing and sniffing while their +traffic uses the working IPv4 TProxy path. The gateway withholds AAAA records because LAN IPv6 +transparent handling is unreliable on this gateway. Its output carries the subscriptions and the +private domains, so never commit it; the secret is filled in on the box, not here. Its binary is a +static release build under `/usr/local/bin`, not a package: update it by hand, validate the live +config with the new core (`mihomo -t -d /etc/mihomo -f `) before swapping, and keep the +previous binary. The release ships no checksums, so TLS plus `-v` is the whole verification. -Gateway mode contract: the tested working combinations are nftables TProxy with both `tun.enable` -and `tun.auto-route` disabled, using either `redir-host` or `fake-ip` DNS. This generator selects -`fake-ip` because it preserves more domain information. Do not combine LAN TProxy with the desktop -TUN auto-route: in this gateway topology it can recapture fake IPv6 dials and cause timeouts. +Gateway mode contract: keep nftables TProxy with both `tun.enable` and `tun.auto-route` disabled, +and keep `dns.ipv6` disabled. The gateway currently withholds AAAA records because LAN IPv6 +transparent handling is unreliable; clients therefore use the working fake-IPv4 path. Do not combine +LAN TProxy with the desktop TUN auto-route: in this gateway topology it can recapture fake dials and +cause timeouts. ## Why generate diff --git a/modules/nixos/desktop/networking/mihomo/gateway-config.nu b/modules/nixos/desktop/networking/mihomo/gateway-config.nu index c5c56547..897694eb 100644 --- a/modules/nixos/desktop/networking/mihomo/gateway-config.nu +++ b/modules/nixos/desktop/networking/mihomo/gateway-config.nu @@ -41,8 +41,9 @@ def main [ | upsert tun.enable false | upsert tun.auto-route false | update tun.strict-route false - # TProxy handles fake IPv4 and IPv6 destinations when the desktop TUN - # auto-route is disabled; fake-IP preserves the domain mapping for LAN flows. + # LAN IPv6 transparent handling is unreliable on the gateway; keep client + # DNS on fake IPv4 so LAN traffic uses the working IPv4 TProxy path. + | upsert dns.ipv6 false | upsert dns.enhanced-mode "fake-ip" # the desktop's resolver is loopback; a gateway serves the LAN instead | update dns.listen ":1053"