[GH-ISSUE #6060] [Question]: EDNS (ECS) leaks through the vless+xhttp #4192

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

Originally created by @JeuDeTarot on GitHub (Jul 20, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6060

What are you trying to do?

Preventing EDNS (ECS) leaks through the tunnel, as well as DNS leaks in general. Of course, server side first.

Setup:

  • Vless+XHTTP+Sniffing inbound, Security=None (h2c 2 transport)
  • TLS is required, but configured through hosts records in the panel (Inbound+Domain:Port+TLS)
  • Steal oneself, panel behind Caddy

Route:

  • Client > VPS (Caddy > Xray) > Web

Test Client:

  • Using Happ, latest, per iOS and Win 11 devices
  • No leaks per iOS at all
  • No specific DNS settings at all, per browser, per tunnel, per router

What have you already tried?

  • Replace / remove headers in Caddy's reverse proxy configuration (X-* and Forwarded, Host, True-Client-IP to 127.0.0.1 or VPS IP) that seems not working with the xhttp and h2c 2 transport itself
  • Sniffing /w fakedns per inbound and fakedns per DNS settings are enabled
  • Skipping fallback and allowing fallbacks
  • Different strategies per outbounds and DNS
  • Different routing rules (even 443 port and dns dat list to catch, yes)

3x-ui version

3.5.0

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 26.04

Screenshots or config snippets

I've tried a lot of settings, so I'm choosing not to add them because I still think it's my misunderstanding of how things work. Just for sure some VPS settings:

/etc/systemd/resolved.conf

[Resolve]
DNS=194.242.2.2 9.9.9.9
FallbackDNS=8.8.8.8 8.8.4.4
Domains=~.
LLMNR=no
MulticastDNS=no
DNSSEC=no
DNSOverTLS=no

/etc/resolv.conf

nameserver 127.0.0.53
options edns0 trust-ad
search .

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 @JeuDeTarot on GitHub (Jul 20, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6060 ### What are you trying to do? Preventing EDNS (ECS) leaks through the tunnel, as well as DNS leaks in general. Of course, server side first. **Setup:** - Vless+XHTTP+Sniffing inbound, Security=None (h2c 2 transport) - TLS is required, but configured through hosts records in the panel (Inbound+Domain:Port+TLS) - Steal oneself, panel behind Caddy **Route:** - Client > VPS (Caddy > Xray) > Web **Test Client:** - Using Happ, latest, per iOS and Win 11 devices - No leaks per iOS at all - No specific DNS settings at all, per browser, per tunnel, per router ### What have you already tried? - Replace / remove headers in Caddy's reverse proxy configuration (`X-*` and `Forwarded`, `Host`, `True-Client-IP` to `127.0.0.1` or `VPS IP`) that seems not working with the xhttp and h2c 2 transport itself - Sniffing /w fakedns per inbound and fakedns per DNS settings are enabled - Skipping fallback and allowing fallbacks - Different strategies per outbounds and DNS - Different routing rules (even 443 port and dns dat list to catch, yes) ### 3x-ui version 3.5.0 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 26.04 ### Screenshots or config snippets I've tried a lot of settings, so I'm choosing not to add them because I still think it's my misunderstanding of how things work. Just for sure some VPS settings: **/etc/systemd/resolved.conf** ``` [Resolve] DNS=194.242.2.2 9.9.9.9 FallbackDNS=8.8.8.8 8.8.4.4 Domains=~. LLMNR=no MulticastDNS=no DNSSEC=no DNSOverTLS=no ``` **/etc/resolv.conf** ``` nameserver 127.0.0.53 options edns0 trust-ad search . ``` ### 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.
Author
Owner

@github-actions[bot] commented on GitHub (Jul 20, 2026):

Server-side, EDNS Client Subnet (ECS) behavior is entirely Xray-core's own dns module, not something 3x-ui implements — the panel's dns/fakedns settings are passed straight through to Xray-core as opaque JSON (internal/xray/config.go, DNSConfig/FakeDNS fields). The relevant panel UI is Xray Configs → DNS (/xray#dns). A few source-grounded points that should help narrow this down:

  1. Client IP is a static, admin-typed value, not something derived per connecting client. It appears in two places: the DNS tab's "General Configs" sub-tab (applies to the whole dns object) and, per server, inside each entry under the DNS sub-tab ("Add Server" → Client IP). The field's own description is "Used to notify the server of the specified IP location during DNS queries" (internal/web/translation/en-US.json) — this is Xray's EDNS Client Subnet option; docs/xray-dns.md in this repo states it plainly: "clientIp sends EDNS Client Subnet data upstream." Neither field is populated by default. Because it's a fixed string rather than something filled in per VLESS connection, Xray's DNS client cannot forward a visiting client's real subnet through this field unless that exact IP was typed in somewhere — worth confirming both are blank, but this is an unlikely source of a leak that would vary per client.

  2. The panel already surfaces an in-UI warning for this exact class of issue as soon as "Enable DNS" is switched on:

    DNS can leak through localhost, plain UDP/TCP, local-mode DoH/DoQ, fallback queries, or EDNS client IP. Use routed DoH, hosts pins, and disable fallback when privacy matters.

    docs/xray-dns.md expands on it. Worth checking whether dns.servers contains any of the following, since all three are documented leak vectors:

    • localhost — uses the VPS's own OS resolver (/etc/resolv.conf, i.e. exactly the systemd-resolved config with 194.242.2.2/9.9.9.9 pasted above), entirely outside Xray's routing/ECS control.
    • a tcp+local://, https+local://, or quic+local:// address — these bypass Xray's routing table by design and dial out from the VPS directly via Freedom.
    • disableFallback: false (the default when a server is added) or enableParallelQuery: true — either can send the same query to more than one upstream provider.
  3. A freshly created inbound/template has no dns object and no fakedns at all (internal/web/service/config.json, the bundled default Xray template), and routing.domainStrategy defaults to AsIs. So unless DNS was explicitly enabled on that tab, any resolution Xray-core itself needs falls back to the VPS's system resolver.

  4. For sniffing's fakedns destOverride to actually short-circuit a query (answer locally with a fake IP, never touching an upstream server), a Fake DNS pool must also exist under DNS → Fake DNS ("Add Fake DNS", IP Pool Subnet + Pool Size) — enabling the dns object does not create one automatically (the panel explicitly resets fakedns to null when DNS is turned on). If the domain(s) used for the ECS test aren't covered by an actual Fake DNS pool entry, they fall through to a real upstream query via whatever dns.servers/system DNS is in effect.

Given point 1, if what you're observing genuinely reproduces your real client subnet (not the VPS's) after confirming Client IP is blank and dns.servers is clean per point 2, the DNS query for that test is most likely never reaching the VPS/Xray at all — i.e. it is being resolved directly by the OS or the client app before the packet enters the VLESS+XHTTP tunnel. That is a conventional client-side DNS leak, and no server-side 3x-ui/Xray config change can fix it.

To go further, it would help to have:

  1. The exact tool/site (or dig/kdig command) used to check for the ECS leak, and the exact subnet/IP it reported.
  2. The dns, fakedns, sniffing, and routing sections of this inbound's Xray config (Xray Configs → Advanced, or raw JSON) — or at minimum, confirmation of what's set for Client IP (both places), dns.servers, and the Fake DNS pool.
  3. Whether the domain used for that specific test is one actually reached through this vless+xhttp inbound from the client, or a background/system lookup outside the tunnel.

This reply was generated automatically. A maintainer (@MHSanaei) may follow up.

<!-- gh-comment-id:5023868646 --> @github-actions[bot] commented on GitHub (Jul 20, 2026): Server-side, EDNS Client Subnet (ECS) behavior is entirely Xray-core's own `dns` module, not something 3x-ui implements — the panel's `dns`/`fakedns` settings are passed straight through to Xray-core as opaque JSON (`internal/xray/config.go`, `DNSConfig`/`FakeDNS` fields). The relevant panel UI is **Xray Configs → DNS** (`/xray#dns`). A few source-grounded points that should help narrow this down: 1. **`Client IP` is a static, admin-typed value, not something derived per connecting client.** It appears in two places: the DNS tab's "General Configs" sub-tab (applies to the whole `dns` object) and, per server, inside each entry under the DNS sub-tab ("Add Server" → `Client IP`). The field's own description is "Used to notify the server of the specified IP location during DNS queries" (`internal/web/translation/en-US.json`) — this is Xray's EDNS Client Subnet option; `docs/xray-dns.md` in this repo states it plainly: "`clientIp` sends EDNS Client Subnet data upstream." Neither field is populated by default. Because it's a fixed string rather than something filled in per VLESS connection, Xray's DNS client cannot forward a *visiting client's* real subnet through this field unless that exact IP was typed in somewhere — worth confirming both are blank, but this is an unlikely source of a leak that would vary per client. 2. The panel already surfaces an in-UI warning for this exact class of issue as soon as "Enable DNS" is switched on: > DNS can leak through localhost, plain UDP/TCP, local-mode DoH/DoQ, fallback queries, or EDNS client IP. Use routed DoH, hosts pins, and disable fallback when privacy matters. `docs/xray-dns.md` expands on it. Worth checking whether `dns.servers` contains any of the following, since all three are documented leak vectors: - `localhost` — uses the VPS's own OS resolver (`/etc/resolv.conf`, i.e. exactly the `systemd-resolved` config with `194.242.2.2`/`9.9.9.9` pasted above), entirely outside Xray's routing/ECS control. - a `tcp+local://`, `https+local://`, or `quic+local://` address — these bypass Xray's routing table by design and dial out from the VPS directly via Freedom. - `disableFallback: false` (the default when a server is added) or `enableParallelQuery: true` — either can send the same query to more than one upstream provider. 3. A freshly created inbound/template has **no `dns` object and no `fakedns` at all** (`internal/web/service/config.json`, the bundled default Xray template), and `routing.domainStrategy` defaults to `AsIs`. So unless DNS was explicitly enabled on that tab, any resolution Xray-core itself needs falls back to the VPS's system resolver. 4. For sniffing's `fakedns` `destOverride` to actually short-circuit a query (answer locally with a fake IP, never touching an upstream server), a Fake DNS pool must also exist under **DNS → Fake DNS** ("Add Fake DNS", IP Pool Subnet + Pool Size) — enabling the `dns` object does not create one automatically (the panel explicitly resets `fakedns` to `null` when DNS is turned on). If the domain(s) used for the ECS test aren't covered by an actual Fake DNS pool entry, they fall through to a real upstream query via whatever `dns.servers`/system DNS is in effect. Given point 1, if what you're observing genuinely reproduces your *real* client subnet (not the VPS's) after confirming `Client IP` is blank and `dns.servers` is clean per point 2, the DNS query for that test is most likely never reaching the VPS/Xray at all — i.e. it is being resolved directly by the OS or the client app before the packet enters the VLESS+XHTTP tunnel. That is a conventional client-side DNS leak, and no server-side 3x-ui/Xray config change can fix it. To go further, it would help to have: 1. The exact tool/site (or `dig`/`kdig` command) used to check for the ECS leak, and the exact subnet/IP it reported. 2. The `dns`, `fakedns`, `sniffing`, and `routing` sections of this inbound's Xray config (Xray Configs → Advanced, or raw JSON) — or at minimum, confirmation of what's set for `Client IP` (both places), `dns.servers`, and the Fake DNS pool. 3. Whether the domain used for that specific test is one actually reached through this vless+xhttp inbound from the client, or a background/system lookup outside the tunnel. *This reply was generated automatically. A maintainer (@MHSanaei) may follow up.*
Author
Owner

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

Server-side, EDNS Client Subnet is handled entirely by Xray-core's dns module — 3x-ui passes your DNS/FakeDNS JSON straight through. A few source-grounded points to narrow this down:

  1. The only ECS knob is Xray Configs → DNS → Client IP — a static, admin-typed value ("Used to notify the server of the specified IP location during DNS queries", which sends EDNS Client Subnet upstream). It's blank by default and is not filled per connecting client, so it can't forward a visiting client's real subnet unless you typed an IP there. Confirm both the general and per-server Client IP fields are empty.
  2. The panel's own DNS warning lists the real leak vectors: localhost servers (use the VPS's /etc/resolv.conf, outside Xray's control), *+local:// servers (bypass routing via Freedom), and disableFallback:false / enableParallelQuery:true. Check dns.servers for these.
  3. A fresh inbound has no dns/fakedns object and domainStrategy:AsIs. For FakeDNS to short-circuit a query you must also add a pool under DNS → Fake DNS.

If the leak still reports your real subnet after Client IP and dns.servers are clean, the query is almost certainly never entering the tunnel — a conventional client-side DNS leak that no server-side change fixes. To dig further, please share the exact test tool/command and reported subnet, plus this inbound's dns/fakedns/sniffing/routing JSON.

<!-- gh-comment-id:5059218512 --> @MHSanaei commented on GitHub (Jul 23, 2026): Server-side, EDNS Client Subnet is handled entirely by Xray-core's `dns` module — 3x-ui passes your DNS/FakeDNS JSON straight through. A few source-grounded points to narrow this down: 1. The only ECS knob is **Xray Configs → DNS → Client IP** — a static, admin-typed value ("Used to notify the server of the specified IP location during DNS queries", which sends EDNS Client Subnet upstream). It's blank by default and is **not** filled per connecting client, so it can't forward a visiting client's real subnet unless you typed an IP there. Confirm both the general and per-server Client IP fields are empty. 2. The panel's own DNS warning lists the real leak vectors: `localhost` servers (use the VPS's `/etc/resolv.conf`, outside Xray's control), `*+local://` servers (bypass routing via Freedom), and `disableFallback:false` / `enableParallelQuery:true`. Check `dns.servers` for these. 3. A fresh inbound has no `dns`/`fakedns` object and `domainStrategy:AsIs`. For FakeDNS to short-circuit a query you must also add a pool under **DNS → Fake DNS**. If the leak still reports your real subnet after Client IP and `dns.servers` are clean, the query is almost certainly never entering the tunnel — a conventional client-side DNS leak that no server-side change fixes. To dig further, please share the exact test tool/command and reported subnet, plus this inbound's `dns`/`fakedns`/`sniffing`/`routing` JSON.
Author
Owner

@JeuDeTarot commented on GitHub (Jul 24, 2026):

Server-side, EDNS Client Subnet is handled entirely by Xray-core's dns module — 3x-ui passes your DNS/FakeDNS JSON straight through. A few source-grounded points to narrow this down:

  1. The only ECS knob is Xray Configs → DNS → Client IP — a static, admin-typed value ("Used to notify the server of the specified IP location during DNS queries", which sends EDNS Client Subnet upstream). It's blank by default and is not filled per connecting client, so it can't forward a visiting client's real subnet unless you typed an IP there. Confirm both the general and per-server Client IP fields are empty.
  2. The panel's own DNS warning lists the real leak vectors: localhost servers (use the VPS's /etc/resolv.conf, outside Xray's control), *+local:// servers (bypass routing via Freedom), and disableFallback:false / enableParallelQuery:true. Check dns.servers for these.
  3. A fresh inbound has no dns/fakedns object and domainStrategy:AsIs. For FakeDNS to short-circuit a query you must also add a pool under DNS → Fake DNS.

If the leak still reports your real subnet after Client IP and dns.servers are clean, the query is almost certainly never entering the tunnel — a conventional client-side DNS leak that no server-side change fixes. To dig further, please share the exact test tool/command and reported subnet, plus this inbound's dns/fakedns/sniffing/routing JSON.

Well, I finally figured out things, and yes, it's impossible to prevent different DNS leakage scenarios just server-side.
Thanks for the clarification, it was helpful.

P.S. Still trying to figure out why the Fake DNS so slow.

<!-- gh-comment-id:5071530927 --> @JeuDeTarot commented on GitHub (Jul 24, 2026): > Server-side, EDNS Client Subnet is handled entirely by Xray-core's `dns` module — 3x-ui passes your DNS/FakeDNS JSON straight through. A few source-grounded points to narrow this down: > > 1. The only ECS knob is **Xray Configs → DNS → Client IP** — a static, admin-typed value ("Used to notify the server of the specified IP location during DNS queries", which sends EDNS Client Subnet upstream). It's blank by default and is **not** filled per connecting client, so it can't forward a visiting client's real subnet unless you typed an IP there. Confirm both the general and per-server Client IP fields are empty. > 2. The panel's own DNS warning lists the real leak vectors: `localhost` servers (use the VPS's `/etc/resolv.conf`, outside Xray's control), `*+local://` servers (bypass routing via Freedom), and `disableFallback:false` / `enableParallelQuery:true`. Check `dns.servers` for these. > 3. A fresh inbound has no `dns`/`fakedns` object and `domainStrategy:AsIs`. For FakeDNS to short-circuit a query you must also add a pool under **DNS → Fake DNS**. > > If the leak still reports your real subnet after Client IP and `dns.servers` are clean, the query is almost certainly never entering the tunnel — a conventional client-side DNS leak that no server-side change fixes. To dig further, please share the exact test tool/command and reported subnet, plus this inbound's `dns`/`fakedns`/`sniffing`/`routing` JSON. Well, I finally figured out things, and yes, it's impossible to prevent different DNS leakage scenarios just server-side. Thanks for the clarification, it was helpful. P.S. Still trying to figure out why the Fake DNS so slow.
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#4192
No description provided.