mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5977] [Bug]: Tunnel inbound listens but does not accept Linux TPROXY TCP traffic in 3x-ui 3.5.0 #4141
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4141
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Slikpro on GitHub (Jul 15, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5977
Describe the bug
A Tunnel inbound created and managed by 3x-ui is listening on the configured port, but it does not accept TCP traffic redirected by Linux nftables TPROXY.
The generated Xray configuration contains the expected settings:
"protocol": "tunnel"
"followRedirect": true
"allowedNetwork": "tcp"
"sockopt": { "tproxy": "tproxy" }
The nftables TPROXY rule matches the client traffic and its packet counter increases. The packet receives firewall mark 1, and policy routing sends marked traffic to local default dev lo table 100.
Xray is listening on the Tunnel inbound port. However, no user Tunnel/dokodemo inbound session appears in the Xray debug log, and no connection is dispatched to the configured outbound.
A Mixed inbound in the same Xray instance works correctly through the same outbound, which confirms that the Xray process, routing rule, SOCKS outbound, upstream SOCKS server, and general network connectivity are functional.
This may be related to #5956 because the affected versions are identical, but the symptom is not limited to the TProxy field being displayed incorrectly in the UI. In this case, transparent traffic is not accepted by the running Tunnel inbound.
Related issues:
#5166
#5339
#5956
Environment
Device: NanoPi NEO3 Plus
Operating system: Debian 13
Architecture: ARM
3x-ui version: 3.5.0
Xray-core version: 26.7.11
Firewall: nftables
Transparent proxy method: Linux TPROXY
LAN interface: eth0
LAN gateway address: 192.168.95.1/24
Test client: 192.168.95.181
WAN interface: eth1
Upstream SOCKS proxy: 192.168.2.44:10809
Network topology
LAN client 192.168.95.181
|
| Default gateway and DNS: 192.168.95.1
v
NanoPi eth0 192.168.95.1
|
| nftables TPROXY -> 127.0.0.1:22222
v
Xray Tunnel inbound :22222
|
| routing rule -> Local-Proxy
v
SOCKS outbound -> 192.168.2.44:10809
A separate Mixed inbound is listening on port 10809 and uses the same Local-Proxy outbound. It works correctly when configured as an explicit HTTP/SOCKS proxy on the client.
Tunnel inbound generated by 3x-ui
{
"listen": "0.0.0.0",
"port": 22222,
"protocol": "tunnel",
"settings": {
"allowedNetwork": "tcp",
"followRedirect": true,
"portMap": {}
},
"sniffing": {
"enabled": false
},
"streamSettings": {
"security": "none",
"sockopt": {
"tcpcongestion": "bbr",
"tproxy": "tproxy"
}
},
"tag": "in-22222-tcp"
}
Routing rule:
{
"type": "field",
"inboundTag": [
"in-22222-tcp"
],
"outboundTag": "Local-Proxy"
}
SOCKS outbound:
{
"protocol": "socks",
"settings": {
"servers": [
{
"address": "192.168.2.44",
"port": 10809,
"users": []
}
]
},
"tag": "Local-Proxy"
}
nftables configuration
table inet xray_tproxy {
chain divert {
type filter hook prerouting priority mangle;
policy accept;
}
The main TPROXY rule counter increases when the LAN client attempts TCP connections. For example, it reached:
374 packets / 19012 bytes
The divert counter remains at zero, which is consistent with no established transparent TCP session being accepted by the listener.
Policy routing
$ ip -4 rule show
0: from all lookup local
100: from all fwmark 0x1/0x1 lookup 100
32766: from all lookup main
32767: from all lookup default
$ ip -4 route show table 100
local default dev lo scope host
The route lookup for a marked packet succeeds:
$ ip -4 route get 1.1.1.1 mark 0x1
local 1.1.1.1 dev lo table 100 src 1.1.1.1 mark 1
Kernel settings
net.ipv4.ip_forward = 1
net.ipv4.conf.all.src_valid_mark = 1
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.eth0.rp_filter = 0
net.ipv4.conf.eth1.rp_filter = 0
The required kernel modules are loaded, including:
nft_socket
nft_tproxy
nf_socket_ipv4
nf_socket_ipv6
nf_tproxy_ipv4
nf_tproxy_ipv6
How to reproduce the problem
Install 3x-ui 3.5.0 with Xray-core 26.7.11 on Debian 13.
Create a working SOCKS outbound named Local-Proxy.
Create a Mixed inbound and confirm that it can use Local-Proxy.
Create a Tunnel inbound on port 22222.
Set:
Allowed network: TCP
Follow redirect: enabled
Sockopt TProxy: tproxy
Add an Xray routing rule from the Tunnel inbound tag to Local-Proxy.
Configure nftables to redirect TCP traffic arriving from the LAN interface to 127.0.0.1:22222 using TPROXY and firewall mark 1.
Add policy routing for mark 1 with a local default route through lo.
Configure another LAN device to use the 3x-ui host as its default gateway.
Generate an external TCP connection from that device without configuring an explicit proxy.
Observe the nftables counters and Xray debug log.
Listener verification
$ ss -lnptu | grep 22222
tcp LISTEN 0 4096 *:22222 : users:(("xray-linux-arm6",pid=...,fd=...))
At some stages both TCP and UDP listeners were visible, although the current diagnostic test is intentionally restricted to TCP.
Packet capture
The LAN interface receives real TCP SYN packets from the client to public destinations:
192.168.95.181: > :80 Flags [S]
192.168.95.181: > :443 Flags [S]
DNS through the gateway also works correctly and is not the cause of the TCP failure.
Xray debug log
For the non-working Tunnel inbound, there are no user requests for external destinations.
The only proxy/dokodemo messages normally visible are internal 3x-ui API requests such as:
proxy/dokodemo: received request for 127.0.0.1:
app/dispatcher: taking detour [api] for [tcp:127.0.0.1:62789]
These messages are generated by the panel API and are unrelated to the LAN client traffic.
For comparison, the working Mixed inbound produces normal log messages:
proxy/http: request to Method [CONNECT] Host [example.com:443]
app/dispatcher: default route for tcp:example.com:443
transport/internet/tcp: dialing TCP to tcp:192.168.2.44:10809
Control tests
The following components have been tested successfully:
LAN connectivity to the NanoPi
DHCP default gateway
DNS through the NanoPi
Xray Mixed inbound on port 10809
Xray dispatcher
Local-Proxy SOCKS outbound
Upstream SOCKS server 192.168.2.44:10809
nftables TPROXY rule matching
Firewall mark assignment
Policy-routing rule
Local route in table 100
Xray listener on port 22222
Kernel TPROXY modules
INPUT firewall policy
The failure is localized after the nftables TPROXY rule is executed and before Xray registers a user session on the Tunnel inbound.
Additional information
3x-ui regenerates the runtime Xray configuration from its database. Manually changing the generated config.json is not a persistent workaround because the panel restores the stored Tunnel configuration after restart or save.
The final generated JSON visibly contains followRedirect: true and sockopt.tproxy: "tproxy", but it is not yet known whether the running listener receives all required socket options or whether the panel introduces another runtime/configuration difference.
A standalone Xray A/B test outside 3x-ui is planned to determine whether the same configuration works when started directly as root. I can provide the result of that test if required.
udp UNCONN 0 0 127.0.0.1:22222 0.0.0.0:* users:(("xray-linux-arm6",pid=1765,fd=41))
tcp LISTEN 0 4096 127.0.0.1:22222 0.0.0.0:* users:(("xray-linux-arm6",pid=1765,fd=34))
tcp LISTEN 0 4096 *:10809 : users:(("xray-linux-arm6",pid=1765,fd=7))
table inet xray_tproxy { # handle 8
chain divert { # handle 1
type filter hook prerouting priority mangle; policy accept;
iifname "eth0" meta nfproto ipv4 meta l4proto tcp socket transparent 1 meta mark set 0x00000001 counter packets 0 bytes 0 accept # handle 3
}
}
Expected behavior
When the nftables TPROXY rule redirects the client TCP connection to port 22222, Xray should:
Accept the connection on the Tunnel inbound.
Recover the original destination through followRedirect.
Create an inbound session with tag in-22222-tcp.
Dispatch the connection to the Local-Proxy outbound.
Connect to the upstream SOCKS proxy.
Record the inbound request in the debug or access log.
An expected log sequence would contain a Tunnel/dokodemo inbound request for the original external destination, followed by a dispatcher route to Local-Proxy.
Actual behavior
The client TCP SYN reaches eth0.
The nftables TPROXY rule matches it.
The TPROXY packet counter increases.
Firewall mark 1 is applied.
The policy-routing rule and table 100 are present.
Xray is listening on port 22222.
No user Tunnel/dokodemo inbound request appears in the Xray debug log.
No session with inbound tag in-22222-tcp is created.
No connection is dispatched to Local-Proxy.
The client TCP connection times out.
3x-ui reports zero traffic for this inbound.
Relevant logs
Screenshots
No response
3x-ui version
3.5.0
Xray-core version
26.7.11
How did you install 3x-ui?
install.sh script
Operating system
Debian 13
Which parts of the panel are affected?
Xray config generation
Browser (only if it is a UI bug)
Not applicable — runtime/network issue
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jul 15, 2026):
Investigated against the pinned Xray-core commit this repo builds against (
go.mod:github.com/xtls/xray-core v1.260327.1-0.20260711155151-50231eaff98c, i.e.XTLS/Xray-core@50231eaff98c) and the 3x-ui config-generation path.Title: Xray-core silently no-ops a failed
IP_TRANSPARENTsetsockopt on the TPROXY listener, and the listener still reportsLISTEN, so a non-transparent socket is indistinguishable from a working one until real traffic is testedSeverity: Medium
Category: Reliability
Why this matters:
First, the generated config is confirmed correct, so this is not a 3x-ui config-generation bug and not a duplicate of #5956 (that one is purely a frontend edit-modal display bug for an existing
sockopt.tproxyvalue).protocol: "tunnel",allowedNetwork,followRedirect,portMap, andstreamSettings.sockopt.tproxyare exactly the field names the pinned Xray-core expects for this proxy, verified directly ininfra/conf/dokodemo.goandproxy/dokodemo/config.proto. On the 3x-ui side,ListenandstreamSettings(which carriessockopt) pass straight from the stored inbound into the runtime config with no rewriting (internal/web/service/inbound.go:370,Listen: r.Listen, plus the raw-JSONStreamSettingspass-through ininternal/database/model/model.go).Second, the actual failure is below the Xray proxy layer. In
proxy/dokodemo/dokodemo.go,Process()only logs"received request for ..."at line 151, and withfollowRedirect: trueit takes the destination purely fromsession.OutboundsFromContext(ctx)(line 114), i.e. whatever the listener already recovered as the original destination. The log in this report shows noproxy/dokodemo: received requestline at all for the LAN traffic (only the unrelated internal[api]dokodemo requests on 127.0.0.1), meaningProcess()is never entered for this traffic. The connection is dropped at the socket/listener level, not inside Xray routing or dispatch logic.That points at
transport/internet/sockopt_linux.go.applyInboundSocketOptionsimplements TPROXY with one call,setsockopt(SOL_IP, IP_TRANSPARENT, 1)(line 212). The caller intransport/internet/system_listener.gotreats a failure there as non-fatal: it only logs it (line 34) and still returns a working listener (see Example). IfIP_TRANSPARENTfails for any reason, Xray still binds and reportsLISTENon the port exactly as observed in this report, but the socket is not actually transparent, so the kernel has no matching socket to deliver a TPROXY connection for a foreign destination to. It is silently dropped, matching the reported symptom precisely: divert counter stays 0, connection times out.This is not hypothetical for this repo: #2859 hit the exact log line
failed to set IP_TRANSPARENT > operation not supportedon a very similar dokodemo/tproxy inbound. That thread never reached a clean fix; reporters saw it resolve inconsistently (disabling AppArmor, disabling kernel MPTCP), pointing at an environment or kernel-capability interaction rather than anything the 3x-ui config controls. Also relevant: thisControlcallback fires once, when Xray creates the listening socket at process start or inbound hot-add, not per connection, so it would not appear in a log window captured only during later traffic tests, which is exactly the window in this report.Recommendation:
No change is indicated in the 3x-ui config generation; it is already correct. Two things would confirm or rule out the
IP_TRANSPARENTtheory:ss -tlnp | grep 22222during the exact tcp-only test. Onessdump later in this report shows the tunnel inbound bound to127.0.0.1:22222rather than0.0.0.0:22222, while the working Mixed inbound is correctly on*:10809. That may be from an earlier test stage as noted in the report, but it is worth reconfirming on the current tcp-only run, since a loopback-only bind would independently cause the same kernel-finds-no-transparent-socket failure. This is confirmed not a 3x-ui-side rewrite (see the pass-through above), so if it recurs, it is not coming from the panel config generation.If (1) confirms
IP_TRANSPARENTis failing, the fix is environment-side, not a 3x-ui code change: the shippedx-ui.service.debianhas noUser=or capability restriction, so an install.sh install already runs Xray as root, so the next thing to check would be AppArmor or other kernel confinement on this NanoPi or Debian 13 image. Separately worth a maintainer look regardless of outcome here: the 3x-ui process supervisor (internal/xray/process.go) never scans the Xray log output for this class of actionable, silently-non-fatal error and never surfaces it in the panel, so operators have no way to learn about it short of full debug-log analysis like this report.Example:
Confidence: high that config generation is correct and that this is a listener or socket-layer failure rather than a routing or config-field problem, both directly verified in source. Moderate that
IP_TRANSPARENTspecifically is the failing call here: it is the best-fitting explanation given the evidence and the #2859 precedent, but unconfirmed without the startup-time log.@MHSanaei
This reply was generated automatically; a maintainer may follow up.
@MHSanaei commented on GitHub (Jul 23, 2026):
The panel emits the correct tunnel config; TPROXY session dispatch is core/host behavior (CAP_NET_ADMIN + policy routing), not panel-side. Closing.