Repository navigation
TUN inbound's autoSystemWfpBlockLeak: Add "all", "allexceptlan", port alone, port range, "tcp"/"udp" alone or with port range, "icmp", and a CIDR in front of any value; Always allow loopback, DHCP and IPv6 neighbor discovery - #7315
Conversation
…p" and port ranges; Always allow loopback, DHCP and IPv6 neighbor discovery
autoSystemWfpBlockLeak now also takes:
- "all": everything outside the TUN, IPv4 and IPv6, in both directions, so
nothing but Xray leaves except through the TUN.
- "tcp", "udp": all ports of that protocol, also written "tcp/0", "udp/0".
- "tcp/<low>-<high>", "udp/<low>-<high>": a range of ports, matched with
FWP_MATCH_RANGE, as two conditions on the same field would match when
either does.
- "icmp": ICMP and ICMPv6, e.g. ping. It takes no port: in ICMP filters the
local port holds the type, and "icmp/0" would read as the echo reply.
Values are normalized: "tcp/0" and "tcp/1-65535" become "tcp", and
"tcp/53-53" becomes "tcp/53".
Whatever is blocked, loopback, which cannot leave the system, and what
Windows itself needs on the local link now always stay allowed: DHCP, DHCPv6,
and IPv6 neighbor and multicast listener discovery. These used to be allowed
only along with "misconfigtun", so "udp" or "icmp" would otherwise have cut
DHCP or IPv6 neighbor discovery, and "tcp" any local proxy, Xray's own
inbounds included. Loopback being allowed means that with "dns", a local
resolver on 127.0.0.1:53 now works for other programs (its own queries to
port 53 or 853 outside the TUN stay blocked), and the DNS Client service
may use it.
"all" reuses the filters of "misconfigtun", which now also let everything
through the TUN, for both IP versions whatever the routes.
On other TUN options: keeping the system's DNS inside the TUN, with "all",
"dns", "windnsclient", or anything covering TCP or UDP port 53 ("udp",
"tcp/50-60", ...), needs dns, as Windows can no longer reach the DNS
servers of the other interfaces; the config is rejected otherwise. Like the
other values, the new ones need autoSystemRoutingTable. The filters do not
need autoOutboundsInterface, as Xray is allowed by its app ID; it still
keeps Xray's own connections out of the TUN's routes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
"allexceptlan" is "all" but for the local network: traffic to and from private (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7), link-local (169.254.0.0/16, fe80::/10), multicast (224.0.0.0/4, ff00::/8) and broadcast (255.255.255.255) addresses stays allowed, so that printers, the router's settings page, or casting to a TV keep working while nothing else leaves outside the TUN. It includes "dns": a resolver on the local network, like the router's, would forward the queries outside the TUN, so DNS stays blocked there. The LAN permit sits below the other values, like the permit through the TUN, so they still apply on the local network, e.g. "tcp/445" blocks Windows file sharing with it. The DNS Client service keeps mDNS and LLMNR, to the local network's addresses only. "all" overrides it. The addresses are matched with FWP_V4_ADDR_MASK and FWP_V6_ADDR_MASK conditions on the remote address, which match when any of them does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With autoSystemWfpBlockLeak, loopback now always stays allowed, so a DNS server in dns like 127.0.0.1, a local resolver, stays reachable although it lies in neither gateway nor autoSystemRoutingTable. Leave loopback servers out of the warning that queries to them cannot go through the TUN and are blocked, and say so in the README. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@patterniha 我又想了下
|
…-65535 "tcp/0" and "udp/0" no longer stand for all ports, which "tcp" and "udp" already say: no syntactic sugar. Port 0 is rejected like any port outside 1-65535. Ranges keep being checked strictly: both ends within 1-65535, the left one not greater than the right one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@patterniha v4v6 的区分比较简单现在就可以做了:"tcpv4"、"udpv6"、"icmpv4",剩下两点先保持现状,契合该功能的定位 |
|
|
…, "udpv6", "icmpv4" and "icmpv6" "v4" or "v6" after the protocol limits a value to one IP version, ports written the same way, e.g. "tcpv4/853" or "udpv6/10-20"; "icmpv4" is ICMP and "icmpv6" is ICMPv6. Their filters go to the ALE layers of that version only. "tcp", "udp" and "icmp" keep covering both. Anything covering TCP or UDP port 53 in either IP version, like "udpv4/53", still needs dns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
autoSystemWfpBlockLeak: Add "all", "allexceptlan", "tcp", "udp", "icmp" and port ranges; Always allow loopback, DHCP and IPv6 neighbor discoveryautoSystemWfpBlockLeak: Add "all", "allexceptlan", "tcp", "udp", "icmp" (also "tcpv4", "udpv6", ...) and port ranges; Always allow loopback, DHCP and IPv6 neighbor discovery
done, doc is also updated. |
|
@patterniha 不使用 "tcpv4" 这种写法了,改为 任何选项前面 都可以加 IP 版本,
TUN 的 README.md 和文档可以写得精简些,等发了这个版本后我来合并文档那两个 PR 吧 |
|
不过可以开头写一句:建议至少配置 "dns" 以阻止 DNS 泄露, 综上,应当更新一下“使用提示”,另外 FreeBSD 也支持 你根据 TUN 的更新把 README.md 和文档缺的都补上吧,XTLS/Xray-docs-next#906 合并进 XTLS/Xray-docs-next#903 |
…f any value instead of "tcpv4" and the like "ipv4:" or "ipv6:" in front of any value limits it to that IP version, e.g. "ipv4:udp/53", "ipv6:all", "ipv4:dns" or "ipv6:misconfigtun". "tcpv4", "udpv6", "icmpv4" and the like are gone. Values that only differ in the IP version become one: "ipv4:udp/53" with "ipv6:udp/53" is "udp/53". "all" overrides "allexceptlan" per IP version, and "all" over one IP version needs dns, as port 53 over one does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… README.md, and shorten it README.md now recommends at least "dns" to block DNS leaks, and lists the values of autoSystemWfpBlockLeak more briefly, "dns" first. It also lists FreeBSD among the systems, and mentions that on Linux, as on Android, the TUN can be a file descriptor from xray.tun.fd (XRAY_TUN_FD). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add "dns" to block DNS over IPv6 as well. Co-Authored-By: Claude Opus 5.5 <[email protected]>
autoSystemWfpBlockLeak: Add "all", "allexceptlan", "tcp", "udp", "icmp" (also "tcpv4", "udpv6", ...) and port ranges; Always allow loopback, DHCP and IPv6 neighbor discoveryautoSystemWfpBlockLeak: Add "all", "allexceptlan", "tcp", "udp", "icmp", port ranges and "ipv4:"/"ipv6:" in front of any value; Always allow loopback, DHCP and IPv6 neighbor discovery
|
code and doc updated. |
|
@patterniha f5cc086 这个是啥意思
至于语法糖,不支持仅写 "CIDR",毕竟有 "all",所以 IPv6 一定要加 |
|
既如此那么只写端口范围 "10-20" 或单个数字比如 "10" 也支持一下吧,TCP 和 UDP 同时,"dns" 的表述也可以简化为三个值了 |
|
|
…instead of "ipv4:" and "ipv6:"; Ports alone for TCP and UDP A CIDR in front of any value limits it to its addresses, an IPv6 one in brackets, e.g. "1.1.1.0/24:53", "[2001:db8::/32]:tcp/853" or "[::/0]:all": "0.0.0.0/0:" and "[::/0]:" take the place of "ipv4:" and "ipv6:". Like autoSystemRoutingTable, it takes CIDRs only, a single address as "8.8.8.8/32", and no GeoIP. "<port>" or "<low>-<high>" alone stands for TCP and UDP, so "dns" is "53", "853" and "windnsclient" now. The filters follow: - One filter per layer permits what goes through the TUN, instead of one for each value. - "all" and "misconfigtun" outweigh the local network that "allexceptlan" leaves open, so with it, "192.168.1.5/32:all" still blocks that address. - The DNS Client service's mDNS and LLMNR stay allowed on the local network only, and only while no other value blocks them. - The warning about blocked DNS servers only names those a value blocks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RPRX f5cc086: "allexceptlan" includes "dns", and with "ipv4:" in front it only included "ipv4:dns", so DNS over IPv6 stayed open unless "dns" was added too. The line said that; now it's part of the CIDR sentence ("0.0.0.0/0:allexceptlan" leaves DNS over IPv6 open). Done in 9638715:
|
autoSystemWfpBlockLeak: Add "all", "allexceptlan", "tcp", "udp", "icmp", port ranges and "ipv4:"/"ipv6:" in front of any value; Always allow loopback, DHCP and IPv6 neighbor discoveryautoSystemWfpBlockLeak: Add "all", "allexceptlan", "tcp", "udp", "icmp", ports alone, port ranges and a CIDR in front of any value; Always allow loopback, DHCP and IPv6 neighbor discovery
|
本来还想支持区分 IP 子协议,不过这样的话又要 "allexcept..." 呃有点烧脑了,况且 TUN 的典型配置是将系统所有 IPv4v6 流量路由进 TUN,除了 TCP、UDP、ICMP 外其它的全没处理, 如果有如此复杂的“挖洞”需求(CIDR、选项),最佳实践是再出一个 excluded 数组,以后再说吧,remote/local、out/in 也是 |
autoSystemWfpBlockLeak: Add "all", "allexceptlan", "tcp", "udp", "icmp", ports alone, port ranges and a CIDR in front of any value; Always allow loopback, DHCP and IPv6 neighbor discoveryautoSystemWfpBlockLeak: Add "all", "allexceptlan", single port & ports range, "tcp", "udp", "icmp" and a CIDR in front of any value; Always allow loopback, DHCP and IPv6 neighbor discovery
autoSystemWfpBlockLeak: Add "all", "allexceptlan", single port & ports range, "tcp", "udp", "icmp" and a CIDR in front of any value; Always allow loopback, DHCP and IPv6 neighbor discoveryautoSystemWfpBlockLeak: Add "all", "allexceptlan", single port & ports range, "tcp", "udp" alone & with ports range, "icmp", and a CIDR in front of any value; Always allow loopback, DHCP and IPv6 neighbor discovery
autoSystemWfpBlockLeak: Add "all", "allexceptlan", single port & ports range, "tcp", "udp" alone & with ports range, "icmp", and a CIDR in front of any value; Always allow loopback, DHCP and IPv6 neighbor discoveryautoSystemWfpBlockLeak: Add "all", "allexceptlan", single port, ports range, "tcp"/"udp" alone / with ports range, "icmp", and a CIDR in front of any value; Always allow loopback, DHCP and IPv6 neighbor discovery
autoSystemWfpBlockLeak: Add "all", "allexceptlan", single port, ports range, "tcp"/"udp" alone / with ports range, "icmp", and a CIDR in front of any value; Always allow loopback, DHCP and IPv6 neighbor discoveryautoSystemWfpBlockLeak: Add "all", "allexceptlan", port alone, port range, "tcp"/"udp" alone / with port range, "icmp", and a CIDR in front of any value; Always allow loopback, DHCP and IPv6 neighbor discovery
autoSystemWfpBlockLeak: Add "all", "allexceptlan", port alone, port range, "tcp"/"udp" alone / with port range, "icmp", and a CIDR in front of any value; Always allow loopback, DHCP and IPv6 neighbor discoveryautoSystemWfpBlockLeak: Add "all", "allexceptlan", port alone, port range, "tcp"/"udp" alone or with port range, "icmp", and a CIDR in front of any value; Always allow loopback, DHCP and IPv6 neighbor discovery
autoSystemWfpBlockLeak now also takes:
"allexceptlan" keeps printers, the router's settings page, casting to a TV, etc. working: private (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7), link-local (169.254.0.0/16, fe80::/10), multicast (224.0.0.0/4, ff00::/8) and broadcast (255.255.255.255) addresses stay allowed in both directions. It includes "dns", so DNS on the local network stays blocked, as a resolver there (like the router) would forward the queries outside the TUN, and the other values still apply there, e.g. "tcp/445" blocks Windows file sharing, and "192.168.1.5/32:all" one device. "0.0.0.0/0:allexceptlan" includes "0.0.0.0/0:dns" only, so "dns" has to be added to block DNS over IPv6 as well. "all" overrides it.
Values are normalized: lower case, "tcp/1-65535" becomes "tcp", "tcp/53-53" becomes "tcp/53", CIDRs are masked ("1.1.1.1/24:53" becomes "1.1.1.0/24:53"), and repeated values are dropped.
Whatever is blocked, loopback, which cannot leave the system, and what Windows itself needs on the local link always stay allowed: DHCP, DHCPv6, and IPv6 neighbor and multicast listener discovery. Before, these were only allowed along with "misconfigtun"; otherwise "udp" or "icmp" would cut DHCP or IPv6 neighbor discovery, and "tcp" any local proxy, Xray's own inbounds included. With "dns", a local resolver on 127.0.0.1:53 now works for other programs as well (its own queries to port 53 or 853 outside the TUN stay blocked), and it can be the TUN's dns server: loopback servers no longer get the "blocked" warning, and the warning only names servers that a value actually blocks.
The filters, from the heaviest, which wins:
"allexceptlan" is the two lightest filters: 7 blocks everything, and 6 lets the local network through. Every other value is heavier, so it still applies on the local network: e.g. the "53" that "allexceptlan" brings along blocks the router's DNS, and "192.168.1.5/32:all" blocks that one device. Likewise, 4 lets mDNS and LLMNR past "windnsclient" (5), but not past another value (3) like "udp". So adding a value can only block more, never open what another value blocks.
Dependencies on other TUN options:
README.md now recommends at least "dns" first, lists the values more briefly, and mentions FreeBSD and Linux's xray.tun.fd where they were missing.
Tested on Windows 11 with a Wintun adapter as the outside interface (250/250 checks):
Follow-up to #7288. Docs: XTLS/Xray-docs-next#903
🤖 Generated with Claude Code