Skip to content

Linux TUN: IPv6 process lookup fails with "not found in /proc/net/tcp6" #7227

Closed

Description

@k1tamura

Integrity requirements

  • I have read all the comments in the issue template and ensured that this issue meet the requirements.
  • I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
  • I provided the complete config and logs, rather than just providing the truncated parts based on my own judgment.
  • I searched issues and did not find any similar issues.
  • The problem can be successfully reproduced in the latest Release

Description

When using Xray's TUN inbound on Linux, routing by process name fails for IPv6 TCP connections. Xray cannot identify the process, so the intended process rule does not match. Traffic falls through to subsequent rules or the default outbound instead. The same rule works for IPv4 TCP.

Reproduced with the official Xray 26.10.21 binary (1b1647c, linux/amd64) on Ubuntu 24.04.5 / WSL2. The minimal example below uses curl, a TUN inbound and two local outbounds.

Expected: both connections select process-match.
Actual: IPv4 selects process-match; IPv6 selects fallback with this error:

[Error] app/router: Unables to find local process name: common/net: connection for fc00::1:41002 not found in /proc/net/tcp6

The likely cause is formatLittleEndianString: it reverses all 16 IPv6 address bytes. However, /proc/net/tcp6 formats each 32-bit word in native byte order while preserving the order of the four words. On little-endian Linux, these produce different lookup strings. IPv4 works because its address contains only one 32-bit word.

Reproduction Method

Save the client config below as config.json alongside the official xray binary. Run on Linux:

sudo unshare --net bash
ip link set lo up
./xray run -c config.json >xray.log 2>&1 &
xray_pid=$!
sleep 1
ip addr add 10.0.0.1/24 dev xray-repro
ip -6 addr add fc00::1/64 dev xray-repro nodad
ip route add 192.0.2.2/32 dev xray-repro
ip -6 route add 2001:db8::2/128 dev xray-repro

curl --noproxy '*' --local-port 41001 --max-time 3 -i http://192.0.2.2/
curl --noproxy '*' --local-port 41002 --max-time 3 -i 'http://[2001:db8::2]/'

kill "$xray_pid"
wait "$xray_pid"
exit
cat xray.log

The commands use an isolated network namespace. IPv4 selects process-match; IPv6 selects fallback.

Client config

Details

{
  "log": {"loglevel": "debug", "dnsLog": true},
  "inbounds": [
    {"tag": "tun-in", "protocol": "tun", "settings": {"name": "xray-repro"}}
  ],
  "outbounds": [
    {"tag": "fallback", "protocol": "blackhole"},
    {"tag": "process-match", "protocol": "blackhole", "settings": {"response": {"type": "http"}}}
  ],
  "routing": {
    "rules": [
      {"type": "field", "process": ["curl"], "outboundTag": "process-match"}
    ]
  }
}

Server config

Details

Not applicable. No server is required.

Client log

Details

Xray 26.10.21 (Xray, Penetrates Everything.) 1b1647c (go1.27.3 linux/amd64)
A unified platform for anti-censorship.
2026/10/22 04:53:08.288725 [Info] infra/conf/serial: Reading config: &{Name:config.json Format:json}
2026/10/22 04:53:08.289617 [Debug] app/log: Logger started
2026/10/22 04:53:08.291793 [Info] proxy/tun: xray-repro created
2026/10/22 04:53:08.292708 [Info] proxy/tun: xray-repro up
2026/10/22 04:53:08.293171 [Warning] core: Xray 26.10.21 started
2026/10/22 04:53:09.290633 [Info] [312366165] proxy/tun: processing from tcp:10.0.0.1:41001 to tcp:192.0.2.2:80
2026/10/22 04:53:09.294028 from tcp:10.0.0.1:41001 accepted tcp:192.0.2.2:80 [tun-in -> process-match]
2026/10/22 04:53:09.294037 [Info] [312366165] app/dispatcher: taking detour [process-match] for [tcp:192.0.2.2:80]
2026/10/22 04:53:09.300980 [Info] [3066045415] proxy/tun: processing from tcp:[fc00::1]:41002 to tcp:[2001:db8::2]:80
2026/10/22 04:53:09.301567 from tcp:[fc00::1]:41002 accepted tcp:[2001:db8::2]:80 [tun-in >> fallback]
2026/10/22 04:53:09.301567 [Error] app/router: Unables to find local process name: common/net: connection for fc00::1:41002 not found in /proc/net/tcp6
2026/10/22 04:53:09.301591 [Info] [3066045415] app/dispatcher: default route for tcp:[2001:db8::2]:80
2026/10/22 04:53:09.302275 [Debug] app/log: Logger closing

Server log

Details

Not applicable. No server is required.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions