[GH-ISSUE #6438] [Feature]: Add DNSTT (DNS Tunneling) inbound for emergency bypass during strict whitelist lockdowns (Iran NIN & Russia LTE blackouts) #4357

Open
opened 2026-10-31 20:39:06 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Iaslav24 on GitHub (Sep 9, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6438

During state-enforced whitelist / default-deny lockdowns:

  • Iran (NIN / National Information Network): When international transit is severed at the TIC gateway level, servers outside the country become 100% unreachable. The network drops into an intranet-only mode where foreign IP ranges are blackholed.
  • Russia (Regional Mobile Blackouts): During drone alerts and localized shutdowns, mobile operators force cellular towers into whitelist-only mode (allowing only domestic banking, VK, and state services), blocking all direct TCP/UDP connections abroad.

Under these conditions, all modern obfuscated protocols (VLESS-Reality, AmneziaWG, Hysteria 2, Shadowsocks) completely fail because foreign IPs and ports are blocked before any TLS/noise handshake can even start.

The only channel that consistently remains open through carrier gateways and recursive resolvers is DNS query traffic on UDP port 53.

Describe the solution you'd like

Integrate DNSTT (DNS Tunneling Tool by David Fifield) into 3x-ui as an emergency "last resort" inbound protocol, either embedded via Go modules or managed as a background runner daemon.

Key Implementation Requirements:

  1. Inbound Configuration:
    • Protocol option: dnstt
    • Domain / NS record configuration (defining the authoritative subdomain).
    • Public/Private key generation (Noise protocol for end-to-end encrypted payload).
    • Transport listener: Raw UDP port 53 (with support for DoH/DoT resolvers).
  2. Internal Routing:
    • Pipe incoming decrypted tunnel traffic directly into 3x-ui's internal dispatcher or local SOCKS5 inbound (127.0.0.1).
  3. Port 53 Helper:
    • Provide an automated check / option to stop or reconfigure systemd-resolved so port 53 can be bound without manual terminal troubleshooting.

Reference: https://www.bamsoftware.com/software/dnstt/

Alternatives you've considered

  1. Two-hop domestic relays (Iran VPS -> Foreign VPS): Fails during total NIN lockdowns when domestic datacenters are completely cut off from international transit.
  2. VLESS-Reality / Trojan / AWG: Useless in default-deny whitelists because destination foreign IPs are not on the carrier's approved list.
  3. Iodine / SlowDNS: Iodine lacks modern cryptography and is instantly flagged and dropped by DPI heuristics. SlowDNS lacks end-to-end Noise protocol encryption and suffers from extreme packet loss. DNSTT is the only modern tool with proper Noise crypto and DoH/DoT resolver compatibility.

Concrete use case

A humanitarian lifeline connection when mobile and broadband networks are pushed into strict white-list isolation:

  1. Iran: Total internet disruptions during national crises, where citizens are trapped inside the intranet NIN with zero foreign IP connectivity.
  2. Russia: Daytime/nighttime regional mobile blackouts where 4G/LTE towers are restricted strictly to state-approved domestic domains.

While DNSTT throughput is modest (100–500 Kbps), it provides critical survivability: it allows users to route low-bandwidth text messaging (Telegram, Signal, Matrix), emergency news feeds, and coordination traffic through public recursive resolvers (Cloudflare, Google, or local ISP DNS) when everything else is completely severed.

Mockups, screenshots, or examples

Architecture diagram:

Client (dnstt-client / mobile app)
↓ Encrypted DNS queries (UDP 53, DoH, or DoT)
Public / ISP Recursive Resolvers (1.1.1.1, 8.8.8.8, Local ISP)
↓ Queries forwarded to authoritative NS
3x-ui Server (dnstt inbound listening on UDP 53)
↓ Noise decryption
Internal Xray Dispatcher / Outbound

Which parts of the panel would this affect?

Backend (API endpoints, login, settings), Frontend (UI / panel pages), Subscription (share links / Clash / JSON), Install / upgrade script

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @Iaslav24 on GitHub (Sep 9, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6438 ### Is your feature request related to a problem? During state-enforced whitelist / default-deny lockdowns: - **Iran (NIN / National Information Network):** When international transit is severed at the TIC gateway level, servers outside the country become 100% unreachable. The network drops into an intranet-only mode where foreign IP ranges are blackholed. - **Russia (Regional Mobile Blackouts):** During drone alerts and localized shutdowns, mobile operators force cellular towers into whitelist-only mode (allowing only domestic banking, VK, and state services), blocking all direct TCP/UDP connections abroad. Under these conditions, **all modern obfuscated protocols (VLESS-Reality, AmneziaWG, Hysteria 2, Shadowsocks) completely fail** because foreign IPs and ports are blocked before any TLS/noise handshake can even start. The only channel that consistently remains open through carrier gateways and recursive resolvers is **DNS query traffic on UDP port 53**. ### Describe the solution you'd like Integrate **DNSTT** (DNS Tunneling Tool by David Fifield) into 3x-ui as an emergency "last resort" inbound protocol, either embedded via Go modules or managed as a background runner daemon. Key Implementation Requirements: 1. **Inbound Configuration:** - Protocol option: `dnstt` - Domain / NS record configuration (defining the authoritative subdomain). - Public/Private key generation (Noise protocol for end-to-end encrypted payload). - Transport listener: Raw UDP port 53 (with support for DoH/DoT resolvers). 2. **Internal Routing:** - Pipe incoming decrypted tunnel traffic directly into 3x-ui's internal dispatcher or local SOCKS5 inbound (127.0.0.1). 3. **Port 53 Helper:** - Provide an automated check / option to stop or reconfigure `systemd-resolved` so port 53 can be bound without manual terminal troubleshooting. Reference: https://www.bamsoftware.com/software/dnstt/ ### Alternatives you've considered 1. **Two-hop domestic relays (Iran VPS -> Foreign VPS):** Fails during total NIN lockdowns when domestic datacenters are completely cut off from international transit. 2. **VLESS-Reality / Trojan / AWG:** Useless in default-deny whitelists because destination foreign IPs are not on the carrier's approved list. 3. **Iodine / SlowDNS:** Iodine lacks modern cryptography and is instantly flagged and dropped by DPI heuristics. SlowDNS lacks end-to-end Noise protocol encryption and suffers from extreme packet loss. DNSTT is the only modern tool with proper Noise crypto and DoH/DoT resolver compatibility. ### Concrete use case A humanitarian lifeline connection when mobile and broadband networks are pushed into strict white-list isolation: 1. **Iran:** Total internet disruptions during national crises, where citizens are trapped inside the intranet NIN with zero foreign IP connectivity. 2. **Russia:** Daytime/nighttime regional mobile blackouts where 4G/LTE towers are restricted strictly to state-approved domestic domains. While DNSTT throughput is modest (100–500 Kbps), it provides critical survivability: it allows users to route low-bandwidth text messaging (Telegram, Signal, Matrix), emergency news feeds, and coordination traffic through public recursive resolvers (Cloudflare, Google, or local ISP DNS) when everything else is completely severed. ### Mockups, screenshots, or examples Architecture diagram: Client (dnstt-client / mobile app) ↓ Encrypted DNS queries (UDP 53, DoH, or DoT) Public / ISP Recursive Resolvers (1.1.1.1, 8.8.8.8, Local ISP) ↓ Queries forwarded to authoritative NS 3x-ui Server (dnstt inbound listening on UDP 53) ↓ Noise decryption Internal Xray Dispatcher / Outbound ### Which parts of the panel would this affect? Backend (API endpoints, login, settings), Frontend (UI / panel pages), Subscription (share links / Clash / JSON), Install / upgrade script ### Are you willing to help? - [ ] I'd like to implement this feature myself and open a PR. - [x] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
Author
Owner

@github-actions[bot] commented on GitHub (Sep 9, 2026):

Valid request and the reasoning about default-deny whitelists is technically sound — but nothing in 3x-ui does this today, and DNSTT cannot be an "inbound" the way VLESS is: it would become a third subsystem living outside Xray, next to internal/mtproto/ and internal/amneziawgnet/. For the record, DNS tunnelling has been asked twice before, so the "not requested before" checkbox in the form isn't accurate: #3903 (DNSTT specifically) and #4389 (MasterDnsVPN / StormDNS), both closed.

Your distinction from the panel's existing xdns mask is correct

The panel already exposes a UDP FinalMask named xdns:

frontend/src/schemas/protocols/stream/finalmask.ts:24-34   UdpMaskTypeSchema: 'salamander', 'mkcp-legacy', 'header-custom', 'xdns', 'xicmp', ...
docs/content/docs/en/config/transports.mdx:128             "UDP masks — salamander, mkcp-legacy, header-custom, xdns, xicmp, noise, sudoku, realm"

That is shaping only. The docs describe FinalMask as something that "wraps traffic after the transport and security layers" (docs/content/docs/en/config/transports.mdx:121-123) — the packets still leave for your server's IP and port on the same socket. Under an IP whitelist that never happens, so xdns does not cover your scenario. Worth stating explicitly, because the earlier DNSTT request drew exactly that objection in its thread.

No DNS-tunnel protocol exists in the panel: the protocol enum is internal/database/model/model.go:24-36 (vmess, vless, tunnel, http, trojan, shadowsocks, mixed, wireguard, hysteria, mtproto, amneziawg), pinned again by the validation tag at internal/database/model/model.go:65.

What integrating dnstt would actually take here

Your "pipe into a local SOCKS5 inbound" idea is not the hard part — that mechanism already exists. AmneziaWG does exactly that, relaying decapsulated traffic into a loopback SOCKS5 Xray inbound that carries one account per client email, because the username is what gives Xray's stats an identity:

internal/amneziawgnet/relay.go:47-61   SocksInboundSettings(emails []string, password string)
internal/amneziawgnet/relay.go:33-39   "...it only needs to satisfy Xray's SOCKS5 inbound requiring *some* username/
                                        password auth before it will accept a connection and use the username as the
                                        stats identity."

The sidecar precedent is MTProto: binary resolved next to the Xray binary (internal/mtproto/process.go:38-41), launched as mtg run <config> (internal/mtproto/process.go:165), and reconciled plus scraped by a cron job that "folds the per-client traffic scraped from each mtg /stats endpoint into the usual client and inbound traffic accounting" (internal/web/job/mtproto_job.go:10-13).

That is the real blocker. The panel's whole client model is per-client — credential, totalGB, expiryTime, IP limit — and mtg-multi only works as a sidecar because it is a fork that exposes per-client secrets, ad-tags and quotas plus a stats endpoint. dnstt-server upstream has a single server keypair and no per-client credential (your own field list has one Private Key / one Public Key), so there is nothing for a client, its quota or its expiry to bind to. That last point about upstream dnstt is inference — I could not read the upstream source from here — but the panel-side requirement it collides with is not.

Beyond that, a new protocol drags the whole chain in CLAUDE.md: a migration in internal/database/db.go, the StructAllow allowlist in tools/openapigen/main.go, frontend/src/pages/api-docs/endpoints.ts, 13 locale files in internal/web/translation/, and the docs. The mtproto sidecar alone touches ~10 files under internal/web/service/ plus its own job.

The parts that can't be delivered as written

  1. Subscription output. The Clash generator handles vmess/vless/trojan/shadowsocks only (internal/sub/clash_service.go:302-324), and there is no dnstt URI scheme that any downstream client (sing-box, mihomo, v2rayNG) parses. Whatever the panel emitted, users would still need dnstt-client configured by hand — so the "Subscription (share links / Clash / JSON)" box in your request has no destination.
  2. The port 53 / systemd-resolved helper. The panel touches neither: there is no systemd-resolved, resolv.conf or port-53 reference anywhere in install.sh or x-ui.sh, and the unit is a plain ExecStart=/usr/local/x-ui/x-ui with no capability grants (x-ui.service.debian:13). A button that reconfigures host DNS resolution is a far larger blast radius than anything the panel does today.

What works today, with no panel change

dnstt-server forwards each tunnelled stream to one upstream TCP address, so point it at an inbound the panel already manages:

  1. Create an inbound (VLESS/TCP/none, or Mixed) and set its listen address to 127.0.0.1 — the field exists (internal/database/model/model.go:63) and the editor exposes it (docs/content/docs/en/config/inbounds.mdx:18-19).
  2. Run dnstt outside the panel, pointed at that loopback port (these are dnstt's own flags, not panel features):
dnstt-keygen -privkey-file server.key -pubkey-file server.pub
dnstt-server -udp :5300 -privkey-file server.key tunnel.example.com 127.0.0.1:<inbound port>

plus your NS delegation for tunnel.example.com and a UDP 53 → 5300 redirect.

  1. Each user runs their normal client inside the tunnel, so the identity stays in the inner protocol (its own UUID) and per-client traffic, quota and expiry accounting keeps working normally. I could not run this here, so treat step 3 as reasoning from the code above rather than a tested result.

Two caveats for that setup: throughput will be whatever dnstt gives you, and per-IP limits stop working for those clients — every connection arrives from loopback, and the core drops 127.0.0.1/[::1] before the IP-limit job ever sees them (internal/web/job/check_client_ip_job.go:113-114).

Whether a full dnstt protocol lands in the panel is the maintainer's call; the code facts above are what that decision rests on. Note that #4389 — the general DNS-tunnelling ask — was closed as not planned, while #3903 was closed as completed even though no DNSTT code exists on the default branch, so neither closure is a decision I can point you to. I'm leaving this one open under enhancement.

Verdict: Feature request (related: #3903, #4389 — same DNS-tunnelling ask, both closed; no shared defect, so nothing to close here)

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5599934462 --> @github-actions[bot] commented on GitHub (Sep 9, 2026): Valid request and the reasoning about default-deny whitelists is technically sound — but nothing in 3x-ui does this today, and DNSTT cannot be an "inbound" the way VLESS is: it would become a **third** subsystem living outside Xray, next to `internal/mtproto/` and `internal/amneziawgnet/`. For the record, DNS tunnelling has been asked twice before, so the "not requested before" checkbox in the form isn't accurate: #3903 (DNSTT specifically) and #4389 (MasterDnsVPN / StormDNS), both closed. ## Your distinction from the panel's existing `xdns` mask is correct The panel already exposes a UDP FinalMask named `xdns`: ``` frontend/src/schemas/protocols/stream/finalmask.ts:24-34 UdpMaskTypeSchema: 'salamander', 'mkcp-legacy', 'header-custom', 'xdns', 'xicmp', ... docs/content/docs/en/config/transports.mdx:128 "UDP masks — salamander, mkcp-legacy, header-custom, xdns, xicmp, noise, sudoku, realm" ``` That is *shaping only*. The docs describe FinalMask as something that "wraps traffic **after** the transport and security layers" (`docs/content/docs/en/config/transports.mdx:121-123`) — the packets still leave for your server's IP and port on the same socket. Under an IP whitelist that never happens, so `xdns` does not cover your scenario. Worth stating explicitly, because the earlier DNSTT request drew exactly that objection in its thread. No DNS-tunnel protocol exists in the panel: the protocol enum is `internal/database/model/model.go:24-36` (`vmess`, `vless`, `tunnel`, `http`, `trojan`, `shadowsocks`, `mixed`, `wireguard`, `hysteria`, `mtproto`, `amneziawg`), pinned again by the validation tag at `internal/database/model/model.go:65`. ## What integrating dnstt would actually take here Your "pipe into a local SOCKS5 inbound" idea is not the hard part — that mechanism already exists. AmneziaWG does exactly that, relaying decapsulated traffic into a loopback SOCKS5 Xray inbound that carries **one account per client email**, because the username is what gives Xray's stats an identity: ``` internal/amneziawgnet/relay.go:47-61 SocksInboundSettings(emails []string, password string) internal/amneziawgnet/relay.go:33-39 "...it only needs to satisfy Xray's SOCKS5 inbound requiring *some* username/ password auth before it will accept a connection and use the username as the stats identity." ``` The sidecar precedent is MTProto: binary resolved next to the Xray binary (`internal/mtproto/process.go:38-41`), launched as `mtg run <config>` (`internal/mtproto/process.go:165`), and reconciled plus scraped by a cron job that "folds the per-client traffic scraped from each mtg `/stats` endpoint into the usual client and inbound traffic accounting" (`internal/web/job/mtproto_job.go:10-13`). That is the real blocker. The panel's whole client model is per-client — credential, `totalGB`, `expiryTime`, IP limit — and `mtg-multi` only works as a sidecar because it is a *fork* that exposes per-client secrets, ad-tags and quotas plus a stats endpoint. `dnstt-server` upstream has a single server keypair and no per-client credential (your own field list has one Private Key / one Public Key), so there is nothing for a client, its quota or its expiry to bind to. That last point about upstream dnstt is inference — I could not read the upstream source from here — but the panel-side requirement it collides with is not. Beyond that, a new protocol drags the whole chain in `CLAUDE.md`: a migration in `internal/database/db.go`, the `StructAllow` allowlist in `tools/openapigen/main.go`, `frontend/src/pages/api-docs/endpoints.ts`, 13 locale files in `internal/web/translation/`, and the docs. The mtproto sidecar alone touches ~10 files under `internal/web/service/` plus its own job. ## The parts that can't be delivered as written 1. **Subscription output.** The Clash generator handles `vmess`/`vless`/`trojan`/`shadowsocks` only (`internal/sub/clash_service.go:302-324`), and there is no dnstt URI scheme that any downstream client (sing-box, mihomo, v2rayNG) parses. Whatever the panel emitted, users would still need `dnstt-client` configured by hand — so the "Subscription (share links / Clash / JSON)" box in your request has no destination. 2. **The port 53 / systemd-resolved helper.** The panel touches neither: there is no `systemd-resolved`, `resolv.conf` or port-53 reference anywhere in `install.sh` or `x-ui.sh`, and the unit is a plain `ExecStart=/usr/local/x-ui/x-ui` with no capability grants (`x-ui.service.debian:13`). A button that reconfigures host DNS resolution is a far larger blast radius than anything the panel does today. ## What works today, with no panel change `dnstt-server` forwards each tunnelled stream to one upstream TCP address, so point it at an inbound the panel already manages: 1. Create an inbound (VLESS/TCP/none, or **Mixed**) and set its **listen address** to `127.0.0.1` — the field exists (`internal/database/model/model.go:63`) and the editor exposes it (`docs/content/docs/en/config/inbounds.mdx:18-19`). 2. Run dnstt outside the panel, pointed at that loopback port (these are dnstt's own flags, not panel features): ```bash dnstt-keygen -privkey-file server.key -pubkey-file server.pub dnstt-server -udp :5300 -privkey-file server.key tunnel.example.com 127.0.0.1:<inbound port> ``` plus your NS delegation for `tunnel.example.com` and a UDP 53 → 5300 redirect. 3. Each user runs their normal client **inside** the tunnel, so the identity stays in the inner protocol (its own UUID) and per-client traffic, quota and expiry accounting keeps working normally. I could not run this here, so treat step 3 as reasoning from the code above rather than a tested result. Two caveats for that setup: throughput will be whatever dnstt gives you, and **per-IP limits stop working for those clients** — every connection arrives from loopback, and the core drops `127.0.0.1`/`[::1]` before the IP-limit job ever sees them (`internal/web/job/check_client_ip_job.go:113-114`). Whether a full `dnstt` protocol lands in the panel is the maintainer's call; the code facts above are what that decision rests on. Note that #4389 — the general DNS-tunnelling ask — was closed as *not planned*, while #3903 was closed as *completed* even though no DNSTT code exists on the default branch, so neither closure is a decision I can point you to. I'm leaving this one open under `enhancement`. Verdict: Feature request (related: #3903, #4389 — same DNS-tunnelling ask, both closed; no shared defect, so nothing to close here) *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Author
Owner

@Iaslav24 commented on GitHub (Sep 9, 2026):

Thank you for this brilliant and in-depth architectural breakdown!

  1. Clarification on Previous Issues:
    Understood regarding #3903 and #4389. The clarification about why FinalMask xdns is fundamentally different from authoritative DNS tunneling during default-deny whitelists is crucial, and I appreciate that the bot highlighted this distinction.

  2. Multi-User Accounting & Architecture:
    The point about dnstt-server lacking per-user authentication is completely fair. Your suggested workaround is actually brilliant: binding an internal VLESS/TCP (or SOCKS) inbound to 127.0.0.1 and pointing standalone dnstt-server to it allows Xray to handle UUIDs, user traffic quotas, and expiry times naturally, completely sidestepping the need to refactor 3x-ui's user database.

  3. Conclusion:
    Even if full native GUI integration is currently too heavy due to subscription schemas and port 53 conflicts, having this documented or offered as an optional auxiliary background service would be a lifesaver for people facing severe regional blackouts.

Thank you for keeping the issue open for the maintainers!

<!-- gh-comment-id:5600015637 --> @Iaslav24 commented on GitHub (Sep 9, 2026): Thank you for this brilliant and in-depth architectural breakdown! 1. **Clarification on Previous Issues:** Understood regarding #3903 and #4389. The clarification about why FinalMask `xdns` is fundamentally different from authoritative DNS tunneling during default-deny whitelists is crucial, and I appreciate that the bot highlighted this distinction. 2. **Multi-User Accounting & Architecture:** The point about `dnstt-server` lacking per-user authentication is completely fair. Your suggested workaround is actually brilliant: binding an internal VLESS/TCP (or SOCKS) inbound to `127.0.0.1` and pointing standalone `dnstt-server` to it allows Xray to handle UUIDs, user traffic quotas, and expiry times naturally, completely sidestepping the need to refactor 3x-ui's user database. 3. **Conclusion:** Even if full native GUI integration is currently too heavy due to subscription schemas and port 53 conflicts, having this documented or offered as an optional auxiliary background service would be a lifesaver for people facing severe regional blackouts. Thank you for keeping the issue open for the maintainers!
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#4357
No description provided.