mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6103] [Question]: VLESS Reality inbound does not work on NAT VPS with dual network interfaces (host network mode) #4217
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#4217
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 @chungl83 on GitHub (Jul 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6103
What are you trying to do?
Title: VLESS Reality inbound does not work on NAT VPS with dual network interfaces (host network mode)
Hello,
I am running 3x-ui on a NAT VPS with two network interfaces:
eth0: outbound interface with default gatewayeth1: inbound interface used for NAT port forwardingNetwork configuration:
eth0:
IP: 10.200.4.39/24
Gateway: 10.200.4.1
Purpose: outbound traffic
eth1:
IP: 172.16.56.12/24
Gateway: 172.16.56.1
Purpose: inbound NAT port forwarding
The VPS provider forwards public ports to
eth1.VPS provider configured policy-based routing for the inbound interface:
default via 172.16.56.1 dev eth1 table t100
ip rule:
32765: from 172.16.56.0/24 lookup t100
3x-ui is running with Docker
network_mode: host.The issue:
network_mode: host.I have verified that Docker bridge networking is not involved.
Could there be any specific Xray/3x-ui configuration requirement for VLESS Reality on a multi-interface NAT VPS environment?
Possible areas I am investigating:
0.0.0.0vs specific interface IP)Could you please advise what logs or configuration details would help diagnose this issue?
Thank you.
What have you already tried?
No response
3x-ui version
3.42
How did you install 3x-ui?
Docker / Docker Compose
Operating system
ubuntu 20.4
Screenshots or config snippets
No response
Before submitting
@MHSanaei commented on GitHub (Jul 25, 2026):
@claude
@github-actions[bot] commented on GitHub (Jul 25, 2026):
Claude finished @MHSanaei's task in 5m 57s —— View job
Answer
There is no interface-specific configuration required for REALITY — 3x-ui already binds every inbound to all interfaces by default, so the dual-NIC/policy-routing layout is very unlikely to be the cause. In
internal/database/model/model.go:277-280, an emptylistenis rewritten to0.0.0.0before the inbound is handed to Xray:The frontend default is the empty string (
frontend/src/schemas/api/inbound.ts:34), so unless you typed something into the Listen IP field, the inbound is on0.0.0.0and covers botheth0andeth1. Withnetwork_mode: hostthe container shares the host network namespace, so that wildcard bind is the host's. Your working panel already proves that inbound TCP oneth1and the return path through tablet100both work.So the failure is almost certainly one of the four things below rather than interface binding. They are ordered by how often they explain "panel reachable, inbound not".
1. Check the Listen IP field is actually empty
If it holds
10.200.4.39(eth0), the inbound will never see NAT traffic arriving oneth1. The field also accepts a Unix socket path —internal/web/translation/en-US.json:685documents that — so a stray value there is worth ruling out first.2. Confirm the inbound port is inside the forwarded range, and that public port == internal port
A NAT VPS normally forwards a small port range, not arbitrary ports. If the REALITY inbound sits on 443 while only e.g. 30000-30020 is forwarded, nothing reaches Xray. The panel port works because it is one of the forwarded ports.
Equally important: if the provider maps public 30001 → internal 443, the share link 3x-ui generates carries the internal port.
internal/sub/service.go:1087builds the endpoint from the inbound's own port, andresolveInboundAddress(internal/sub/service.go:1138-1166) never advertises a wildcard bind — it falls back to the configured panel/subscription domain and then to the request Host header. Behind NAT that fallback can end up being a private address.Two supported ways to fix the advertised endpoint:
dest+port(frontend/src/schemas/protocols/stream/external-proxy.ts:14-29) and the link generators fan out one link per row, so you can advertisepublic-ip:30001while Xray keeps listening on 443.shareAddrStrategy/shareAddron the inbound; help text atinternal/web/translation/en-US.json:686-689). This overrides only the host, not the port.Verify from outside the VPS:
and on the VPS:
3. Verify the REALITY target is reachable from the VPS
This is the real behavioural difference between REALITY and a shadowsocks-rust container. REALITY does not just accept a connection — during the handshake the server relays the client's ClientHello to
target/destand needs a working TLS 1.3 + X25519 + trusted-certificate response back. If egress frometh0to that host on 443 is blocked or slow, connections fail even though the TCP listener is perfectly reachable. Shadowsocks needs nothing third-party at connect time, which is why it can work while REALITY does not.The panel has a built-in probe that dials from the server itself: the search button next to Dest in the REALITY section of the inbound form (
frontend/src/pages/inbounds/form/security/reality.tsx), backed byPOST /panel/api/server/scanRealityTarget(internal/web/controller/server.go:81, logic ininternal/web/service/reality_scan.go). It reports TLS version, ALPN, curve, and certificate validity, plus a reason string on failure. The radar button opens the bulk scanner (scanRealityTargets) if you want to pick a better target.Manual equivalent on the VPS:
Note that clock skew is not the culprit under panel defaults —
maxTimediffdefaults to0(frontend/src/schemas/protocols/security/reality.ts), which leaves the server-side time check off.4. Rule out the bundled Fail2ban, which is enabled by default in Docker
docker-compose.ymlshipsXUI_ENABLE_FAIL2BAN: "true"withNET_ADMIN/NET_RAW. Withnetwork_mode: host, the jail's chain is inserted into the host'sINPUTchain, andDockerEntrypoint.shbuilds the ban action so that it exempts only the SSH ports and the panel port:A banned client keeps full access to the panel and loses every Xray inbound — exactly your symptom. It only triggers for clients with an IP limit set (
internal/web/job/check_client_ip_job.go:483returns early whenlimitIp <= 0), so check:One caveat visible in the entrypoint: the exempt port list is computed once at container start, so if you changed the panel port afterwards the exemption is stale.
The logs you asked for
Two settings hide exactly the evidence you need, both on by default.
Xray side. The shipped template (
internal/web/service/config.json:20-26) is:access: "none"means the dashboard access-log viewer (Xray status card → Access Logs,POST /panel/api/server/xraylogs/:count) has no file to read —GetXrayLogsresolves the path from this config and returnsnilwhen it cannot open it (internal/web/service/server.go:1187-1195). In Panel → Xray Configs, set:/var/log/x-uiis the log folder the Docker entrypoint already creates (XUI_LOG_FOLDERdefault).Panel side. Xray's stderr/stdout is piped into the panel logger (
internal/xray/process.go:541-542), butinternal/xray/log_writer.go:76-82demotes precisely the interesting lines:The panel default level is
info(internal/config/config.go:90-99), so REALITY handshake failures are silently dropped. Add to your composeenvironment:and recreate the container:Then read the panel log (
POST /panel/api/server/logs/:count, ordocker logs 3xui_app).How to interpret the result: attempt a client connection and look at the access log.
tls handshake error/connection endsline appears → the packets do arrive and REALITY is rejecting or failing the handshake. That points at the target/SNI/keys, or at egress todest(item 3).If you open a follow-up
Please include: the inbound's
listenvalue and port, the public port your provider forwards to it, the REALITYdest/targetandserverNames, the result of the panel's Dest scan button, and the panel log atdebugaround a failed connection attempt. Please redactprivateKeyand client UUIDs.One aside: you listed version 3.42, which I read as v3.4.2. The current release is v3.5.0, so it is worth retesting there before digging further.
Note that
sockopt.interfaceandsockopt.markdo exist in the panel's stream settings (frontend/src/schemas/protocols/stream/sockopt.ts), but neither should be needed here — your source-basedip rulealready handles the reply path, which the working panel confirms.This workflow only investigates and replies; no files were changed.
@chungl83 commented on GitHub (Jul 27, 2026):
Thank you for the detailed analysis and suggestions.
I have identified the root cause. The issue was not related to the dual NIC configuration, policy routing, or the REALITY inbound listen address.
The problem was caused by the MTU setting on the VPS network interface. After adjusting the MTU to 1418, the VLESS + REALITY inbound started working normally.
My final configuration:
network_mode: hosteth1eth01418Before changing the MTU:
After changing the MTU:
This was likely caused by path MTU issues in the NAT VPS environment, where the REALITY TLS handshake packets were affected.
Thank you again for pointing me in the right direction and for the detailed troubleshooting guidance.