Skip to content

TUN inbound: Start on Windows when IPv6 is disabled system-wide - #6874

Merged
RPRX merged 1 commit into
XTLS:mainfrom
nSQUICK:tun-windows-ipv6-disabled
Oct 5, 2026
Merged

RPRX merged 1 commit into
XTLS:mainfrom
nSQUICK:tun-windows-ipv6-disabled

Conversation

@nSQUICK

@nSQUICK nSQUICK commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

On Windows with IPv6 disabled system-wide, a freshly created Wintun adapter has no IPv6 interface. Start() configures both address families unconditionally, so t.luid.IPInterface(windows.AF_INET6) returns ERROR_NOT_FOUND and the inbound fails, even though the config has no IPv6 gateway or route:

[Info] proxy/tun: [tun] update interface Wi-Fi 8
[Info] proxy/tun: Konor created
Failed to start: app/proxyman/inbound: failed to start proxy > Element not found.

This change skips the IPv6 family when its interface does not exist and nothing in the config needs it (gateway and autoSystemRoutingTable are IPv4-only). A config that asks for IPv6 still fails as before.

Where it was seen: a Windows 11 machine with no IPv6 address on any adapter and only loopback entries in the IPv6 route table. Turning IPv6 off is common advice in "fix" guides, so such systems are not rare.

Config used: "gateway": ["172.19.0.1/30"], "autoSystemRoutingTable": ["0.0.0.0/0"], "autoOutboundsInterface": "auto".

Testing: on that machine v26.9.9 failed on every start; v26.9.9 with this patch starts and carries traffic. On main I only checked that it builds and passes go vet for windows/amd64.

With IPv6 turned off for the whole system, a new Wintun adapter gets no
IPv6 interface, so luid.IPInterface(AF_INET6) returns ERROR_NOT_FOUND and
the inbound fails with "failed to start proxy > Element not found." even
when the config has no IPv6 gateway or route.

Skip the IPv6 family in that case. A config that asks for IPv6 still
fails as before.
@x15rte

x15rte commented Oct 2, 2026

Copy link
Copy Markdown

REAL

@x15rte

x15rte commented Oct 2, 2026

Copy link
Copy Markdown

my ai agent said
Cause

  • The machine has HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\DisabledComponents = 0xFF, so no non-loopback interface, wintun included, has an IPv6 interface.
  • WindowsTun.Start() loops over {AF_INET, AF_INET6} and calls t.luid.IPInterface(family) for both families, even when the config has no v6 route or address (route6 and address6 are false).
  • The v6 call returns ERROR_NOT_FOUND (1168). That path is return err, not the startOver retry, and it isn't wrapped like "unable to set routes". So the log shows only Element not found.

I confirmed it by calling the Win32 API directly on a freshly created wintun adapter. CreateAdapter, StartSession and GetIpInterfaceEntry(AF_INET) succeed. GetIpInterfaceEntry(AF_INET6) returns 1168. sing-tun
on the same machine and adapter type works.

Expected
Skip the per-family interface setup when the config has no route or address for that family, as the pre-#6478 code did. Failing that, treat ERROR_NOT_FOUND from a family the config doesn't use as non-fatal,
and wrap the error so the log says which call failed.

@RPRX
RPRX requested review from LjhAUMEM and patterniha October 5, 2026 03:37
@RPRX

RPRX commented Oct 5, 2026

Copy link
Copy Markdown
Member

见过很多路由器只给 IPv4 地址的,不过应该与这个 PR 无关吧不然早有 issue 了

至于 Windows 系统级关掉了 IPv6 的情况,应该主要是政府/企业机器为了符合安全要求

@RPRX
RPRX merged commit 1e08d48 into XTLS:main Oct 5, 2026
patterniha added a commit to patterniha/PattN that referenced this pull request Oct 20, 2026
Where the OS keeps IPv6 off on new interfaces (Windows with the
DisabledComponents bit 0x10, which 0xFF includes, from the next
restart; Linux with net.ipv6.conf.default.disable_ipv6 set or without
the IPv6 stack), a TUN asked for an IPv6 address or route does not
start: Xray-core leaves IPv6 out only when the config asks for none
(XTLS/Xray-core#6874). "Enable IPv6 Address" then counts for nothing,
so the Xray and sing-box TUNs get no IPv6 address, and sing-box's
fake-IP server no IPv6 range.

A global IPv6 address that an interface made earlier still holds would
bypass such a TUN. Outside Windows strict route, where misconfigtun
blocks it, the TUN then keeps asking for IPv6 as before, and fails to
start rather than let that IPv6 out. The check reads the OS settings
rather than the interfaces, so a host that is not connected yet still
counts as having IPv6.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
patterniha added a commit that referenced this pull request Oct 29, 2026
…nt changes in README

Covers #7173 (a connection that cannot be bound fails
instead of leaving unbound), #7214 (IPv4-only and IPv6-only outbound
interfaces on Windows), #7230 (IPV6_BOUND_IF on macOS), and also #7130
(built-in TCP/IP stack), #6874 (IPv6 disabled system-wide on Windows),
#6811 (an existing Wintun adapter is reused) and #6883 (the iOS fd is
duplicated). #7092 and autoSystemWfpBlockLeak were already covered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
patterniha added a commit that referenced this pull request Nov 7, 2026
…onents` turns IPv6 off, with "misconfigtun" blocking IPv6 then

#7341 (comment)

IPv6 entries are no longer left out. With IPv6 turned off by
DisabledComponents (0x10, the non-tunnel interfaces, the TUN among them,
as in 0xFF), IPv6 is set up as usual, and errors doing so, clearing its
DNS servers included, are only logged; otherwise they exit, also for a
config without IPv6 entries, which replaces the skips of #6874, #7325 and
#7332. "misconfigtun" then blocks IPv6 outside the TUN whatever the routes,
as IPv6 still works until the reboot that applies the value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
RPRX pushed a commit that referenced this pull request Nov 8, 2026
… `DisabledComponents` turns IPv6 off, with "misconfigtun" blocking IPv6 then (#7341)

#7325 (comment)
#7332 (comment)
#7341 (comment)

Replaces #7332, #7325 and #6874

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
RPRX pushed a commit that referenced this pull request Nov 8, 2026
…outingTable`) instead of exiting on Windows when `DisabledComponents` turns IPv6 off, with `autoSystemWfpBlockLeak`'s "misconfigtun" blocking IPv6 then (#7341)

#7325 (comment)
#7332 (comment)
#7341 (comment)

Replaces #7332, #7325 and #6874

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

5 participants