[GH-ISSUE #6103] [Question]: VLESS Reality inbound does not work on NAT VPS with dual network interfaces (host network mode) #4217

Closed
opened 2026-10-31 20:38:03 +07:00 by bsakaguchi · 3 comments
Owner

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 gateway
  • eth1: inbound interface used for NAT port forwarding

Network 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:

  • 3x-ui web panel is accessible through the forwarded NAT port successfully.
  • However, VLESS + Reality inbound cannot establish a connection.
  • The same NAT VPS works correctly with another proxy application (Shadowrocket Rust Docker) using network_mode: host.
  • Therefore, the NAT forwarding and basic routing appear to be working.

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:

  • Xray listening address (0.0.0.0 vs specific interface IP)
  • Reality inbound handling on multiple interfaces
  • Source IP binding or reply routing
  • TCP connection handling differences compared with other proxy implementations

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

  • I read the Wiki and searched existing issues.
  • This is a usage question, not a bug report.
  • This question is written in English.
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 gateway * `eth1`: inbound interface used for NAT port forwarding Network 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: * 3x-ui web panel is accessible through the forwarded NAT port successfully. * However, VLESS + Reality inbound cannot establish a connection. * The same NAT VPS works correctly with another proxy application (Shadowrocket Rust Docker) using `network_mode: host`. * Therefore, the NAT forwarding and basic routing appear to be working. 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: * Xray listening address (`0.0.0.0` vs specific interface IP) * Reality inbound handling on multiple interfaces * Source IP binding or reply routing * TCP connection handling differences compared with other proxy implementations 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 - [x] I read the [Wiki](https://github.com/MHSanaei/3x-ui/wiki) and searched [existing issues](../issues?q=is%3Aissue). - [x] This is a usage question, not a bug report. - [x] This question is written in English.
bsakaguchi 2026-10-31 20:38:03 +07:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@MHSanaei commented on GitHub (Jul 25, 2026):

@claude

<!-- gh-comment-id:5080303901 --> @MHSanaei commented on GitHub (Jul 25, 2026): @claude
Author
Owner

@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 empty listen is rewritten to 0.0.0.0 before the inbound is handed to Xray:

listen := i.Listen
if listen == "" {
    listen = "0.0.0.0"
}

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 on 0.0.0.0 and covers both eth0 and eth1. With network_mode: host the container shares the host network namespace, so that wildcard bind is the host's. Your working panel already proves that inbound TCP on eth1 and the return path through table t100 both 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 on eth1. The field also accepts a Unix socket path — internal/web/translation/en-US.json:685 documents 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:1087 builds the endpoint from the inbound's own port, and resolveInboundAddress (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:

  • External Proxy rows on the inbound's stream settings. Each row carries its own 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 advertise public-ip:30001 while Xray keeps listening on 443.
  • Share address strategy = Custom plus Custom share address set to your public IP or hostname (shareAddrStrategy / shareAddr on the inbound; help text at internal/web/translation/en-US.json:686-689). This overrides only the host, not the port.

Verify from outside the VPS:

nc -vz <public-ip> <public-port>

and on the VPS:

ss -lntp | grep -w <internal-port>

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/dest and needs a working TLS 1.3 + X25519 + trusted-certificate response back. If egress from eth0 to 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 by POST /panel/api/server/scanRealityTarget (internal/web/controller/server.go:81, logic in internal/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:

openssl s_client -connect <dest-host>:443 -servername <your-sni> -tls1_3 </dev/null

Note that clock skew is not the culprit under panel defaults — maxTimediff defaults to 0 (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.yml ships XUI_ENABLE_FAIL2BAN: "true" with NET_ADMIN/NET_RAW. With network_mode: host, the jail's chain is inserted into the host's INPUT chain, and DockerEntrypoint.sh builds the ban action so that it exempts only the SSH ports and the panel port:

actionban = <iptables> -I f2b-<name> 1 -s <ip> -p tcp -m multiport ! --dports <exemptports> -j <blocktype>
...
exemptports = $EXEMPT_PORTS   # SSH ports + 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:483 returns early when limitIp <= 0), so check:

docker exec 3xui_app fail2ban-client status 3x-ipl
iptables -S | grep f2b

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:

"log": {
  "access": "none",
  "dnsLog": false,
  "error": "",
  "loglevel": "warning",
  "maskAddress": ""
}

access: "none" means the dashboard access-log viewer (Xray status card → Access Logs, POST /panel/api/server/xraylogs/:count) has no file to read — GetXrayLogs resolves the path from this config and returns nil when it cannot open it (internal/web/service/server.go:1187-1195). In Panel → Xray Configs, set:

"log": {
  "access": "/var/log/x-ui/access.log",
  "error": "",
  "loglevel": "debug",
  "dnsLog": false,
  "maskAddress": ""
}

/var/log/x-ui is the log folder the Docker entrypoint already creates (XUI_LOG_FOLDER default).

Panel side. Xray's stderr/stdout is piped into the panel logger (internal/xray/process.go:541-542), but internal/xray/log_writer.go:76-82 demotes precisely the interesting lines:

if strings.Contains(msgBodyLower, "tls handshake error") ||
    strings.Contains(msgBodyLower, "connection ends") {
    logger.Debug("XRAY: " + msgBody)

The panel default level is info (internal/config/config.go:90-99), so REALITY handshake failures are silently dropped. Add to your compose environment: and recreate the container:

XUI_LOG_LEVEL: "debug"

Then read the panel log (POST /panel/api/server/logs/:count, or docker logs 3xui_app).

How to interpret the result: attempt a client connection and look at the access log.

  • Nothing at all appears, and no handshake line in the panel log → the packets never reached Xray. The problem is the NAT port forward or the port choice, not Xray or REALITY.
  • A tls handshake error / connection ends line appears → the packets do arrive and REALITY is rejecting or failing the handshake. That points at the target/SNI/keys, or at egress to dest (item 3).

If you open a follow-up

Please include: the inbound's listen value and port, the public port your provider forwards to it, the REALITY dest/target and serverNames, the result of the panel's Dest scan button, and the panel log at debug around a failed connection attempt. Please redact privateKey and 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.interface and sockopt.mark do exist in the panel's stream settings (frontend/src/schemas/protocols/stream/sockopt.ts), but neither should be needed here — your source-based ip rule already handles the reply path, which the working panel confirms.


  • Read the issue thread in full
  • Trace how 3x-ui builds the Xray inbound listen address
  • Check REALITY-specific config generation and the target probe
  • Identify the likely causes and the diagnostics to request
  • Post the answer

This workflow only investigates and replies; no files were changed.

<!-- gh-comment-id:5080304512 --> @github-actions[bot] commented on GitHub (Jul 25, 2026): **Claude finished @MHSanaei's task in 5m 57s** —— [View job](https://github.com/MHSanaei/3x-ui/actions/runs/30172187678) --- ### 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 empty `listen` is rewritten to `0.0.0.0` before the inbound is handed to Xray: ```go listen := i.Listen if listen == "" { listen = "0.0.0.0" } ``` 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 on `0.0.0.0` and covers both `eth0` and `eth1`. With `network_mode: host` the container shares the host network namespace, so that wildcard bind is the host's. Your working panel already proves that inbound TCP on `eth1` and the return path through table `t100` both 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 on `eth1`. The field also accepts a Unix socket path — `internal/web/translation/en-US.json:685` documents 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:1087` builds the endpoint from the inbound's own port, and `resolveInboundAddress` (`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: - **External Proxy** rows on the inbound's stream settings. Each row carries its own `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 advertise `public-ip:30001` while Xray keeps listening on 443. - **Share address strategy = Custom** plus **Custom share address** set to your public IP or hostname (`shareAddrStrategy` / `shareAddr` on the inbound; help text at `internal/web/translation/en-US.json:686-689`). This overrides only the host, not the port. Verify from outside the VPS: ```bash nc -vz <public-ip> <public-port> ``` and on the VPS: ```bash ss -lntp | grep -w <internal-port> ``` ### 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`/`dest` and needs a working TLS 1.3 + X25519 + trusted-certificate response back. If egress from `eth0` to 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 by `POST /panel/api/server/scanRealityTarget` (`internal/web/controller/server.go:81`, logic in `internal/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: ```bash openssl s_client -connect <dest-host>:443 -servername <your-sni> -tls1_3 </dev/null ``` Note that clock skew is not the culprit under panel defaults — `maxTimediff` defaults to `0` (`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.yml` ships `XUI_ENABLE_FAIL2BAN: "true"` with `NET_ADMIN`/`NET_RAW`. With `network_mode: host`, the jail's chain is inserted into the **host's** `INPUT` chain, and `DockerEntrypoint.sh` builds the ban action so that it exempts only the SSH ports and the panel port: ``` actionban = <iptables> -I f2b-<name> 1 -s <ip> -p tcp -m multiport ! --dports <exemptports> -j <blocktype> ... exemptports = $EXEMPT_PORTS # SSH ports + 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:483` returns early when `limitIp <= 0`), so check: ```bash docker exec 3xui_app fail2ban-client status 3x-ipl iptables -S | grep f2b ``` 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: ```json "log": { "access": "none", "dnsLog": false, "error": "", "loglevel": "warning", "maskAddress": "" } ``` `access: "none"` means the dashboard access-log viewer (Xray status card → Access Logs, `POST /panel/api/server/xraylogs/:count`) has no file to read — `GetXrayLogs` resolves the path from this config and returns `nil` when it cannot open it (`internal/web/service/server.go:1187-1195`). In **Panel → Xray Configs**, set: ```json "log": { "access": "/var/log/x-ui/access.log", "error": "", "loglevel": "debug", "dnsLog": false, "maskAddress": "" } ``` `/var/log/x-ui` is the log folder the Docker entrypoint already creates (`XUI_LOG_FOLDER` default). **Panel side.** Xray's stderr/stdout is piped into the panel logger (`internal/xray/process.go:541-542`), but `internal/xray/log_writer.go:76-82` demotes precisely the interesting lines: ```go if strings.Contains(msgBodyLower, "tls handshake error") || strings.Contains(msgBodyLower, "connection ends") { logger.Debug("XRAY: " + msgBody) ``` The panel default level is `info` (`internal/config/config.go:90-99`), so REALITY handshake failures are silently dropped. Add to your compose `environment:` and recreate the container: ```yaml XUI_LOG_LEVEL: "debug" ``` Then read the panel log (`POST /panel/api/server/logs/:count`, or `docker logs 3xui_app`). **How to interpret the result:** attempt a client connection and look at the access log. - Nothing at all appears, and no handshake line in the panel log → the packets never reached Xray. The problem is the NAT port forward or the port choice, not Xray or REALITY. - A `tls handshake error` / `connection ends` line appears → the packets do arrive and REALITY is rejecting or failing the handshake. That points at the target/SNI/keys, or at egress to `dest` (item 3). --- ### If you open a follow-up Please include: the inbound's `listen` value and port, the public port your provider forwards to it, the REALITY `dest`/`target` and `serverNames`, the result of the panel's Dest scan button, and the panel log at `debug` around a failed connection attempt. Please redact `privateKey` and 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.interface` and `sockopt.mark` do exist in the panel's stream settings (`frontend/src/schemas/protocols/stream/sockopt.ts`), but neither should be needed here — your source-based `ip rule` already handles the reply path, which the working panel confirms. --- - [x] Read the issue thread in full - [x] Trace how 3x-ui builds the Xray inbound listen address - [x] Check REALITY-specific config generation and the target probe - [x] Identify the likely causes and the diagnostics to request - [x] Post the answer This workflow only investigates and replies; no files were changed.
Author
Owner

@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:

  • Docker mode: network_mode: host
  • Inbound interface: eth1
  • Outbound interface: eth0
  • Policy routing: unchanged
  • MTU: 1418

Before changing the MTU:

  • The panel was accessible through the NAT forwarded port.
  • TCP connectivity was available.
  • However, VLESS + REALITY handshake failed.

After changing the MTU:

  • VLESS + REALITY connection works successfully.

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.

<!-- gh-comment-id:5086832531 --> @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: * Docker mode: `network_mode: host` * Inbound interface: `eth1` * Outbound interface: `eth0` * Policy routing: unchanged * MTU: `1418` Before changing the MTU: * The panel was accessible through the NAT forwarded port. * TCP connectivity was available. * However, VLESS + REALITY handshake failed. After changing the MTU: * VLESS + REALITY connection works successfully. 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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4217
No description provided.