mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #5871] [Feature]: passing dns request throught outbound #4077
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#4077
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 @harryngne on GitHub (Jul 9, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5871
Is your feature request related to a problem?
Hi!
Is it possible to pass DNS requests through wireguard outbound too? Because when you set wireguard as the outbound (first one), and you test for dns leak, it will still be resolved by your server resolver, not the wireguard server. e.g, if the server is located in Germany and the wireguard node is located in USA, the DNS leak locations will be from Germany server (unlike the IP which is successfully from USA).
Describe the solution you'd like
I suggest adding an option in the DNS settings to route DNS queries through a specified outbound. This would help prevent DNS leaks when traffic goes from Node A (transit node) to Node B (outbound node). It would be a useful feature for users running multi-node proxy setups with 3x-ui.
Alternatives you've considered
No response
Concrete use case
No response
Mockups, screenshots, or examples
No response
Which parts of the panel would this affect?
No response
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Jul 9, 2026):
This is already possible today with the panel's existing settings — it does not require a new field, just combining two settings that already exist.
wg-dns). This is thetagfield onDnsServerObjectInnerSchema(frontend/src/schemas/dns.ts:25), exposed in the DNS server form (frontend/src/pages/xray/dns/DnsServerModal.tsx:181). Its own description in the UI states: "This tag will be available as an Inbound tag in routing rules" (internal/web/translation/en-US.json:1947).wg-dns) and Outbound Tag set to your WireGuard (or other transit) outbound. The Routing tab automatically adds every DNS server's tag to the Inbound Tag choices (frontend/src/pages/xray/routing/RoutingTab.tsx:124-127), and the rule editor exposes bothinboundTagandoutboundTag(frontend/src/pages/xray/routing/RuleFormModal.tsx:286-295).In Xray-core's DNS subsystem, a server's
tagmarks its outgoing queries as if coming from an inbound with that name, so a normal routing rule can then send just those queries out through any outbound — including WireGuard — which is what you'd want for a Node A (transit) → Node B (outbound) setup. I have not run this against a live instance myself, so please test with a DNS leak checker after configuring it and report back whether it resolves through Node B.This is distinct from #5853, #3453, and #2460 (all closed), which asked for a
DNS =-style field built directly into the WireGuard outbound settings (like a wg-quick config), so WireGuard could resolve against a server reachable only inside its own tunnel. That field still does not exist:frontend/src/schemas/protocols/outbound/wireguard.tsonly definesmtu,secretKey,address,domainStrategy,reserved,peers,noKernelTun. (#3453 was closed as completed on 2026-05-29 without a corresponding code change, then effectively re-filed as #5853 and closed again on 2026-07-08.) The tag + routing rule approach above only works if the DNS server address is reachable from the outbound (a normal public resolver); it will not help if you need to resolve against an address that exists only inside the WireGuard peer's private network.Since you're offering to open a PR: please confirm first whether the tag + routing rule approach above solves the leak for your setup. This mechanism is currently undocumented (no mention in
README.mdordocs/), so even a documentation addition would help other users hitting the same question. @MHSanaei — worth deciding whether a more direct, one-step control (e.g. an outbound selector on the DNS server entry that generates the routing rule automatically) is wanted on top of the existing mechanism, or whether documenting the current workflow is enough.This reply was generated automatically and a maintainer may follow up.
@harryngne commented on GitHub (Jul 9, 2026):
Thanks for the explanation. The tag + routing rule approach can solve DNS leak for normal DNS queries, but I think it does not fully solve the transit node use case.
In a Node A (transit) → Node B (WireGuard outbound) setup, Node A may need DNS to resolve the WireGuard endpoint domain first. If Node A’s DNS is unavailable, it cannot establish the tunnel to Node B, so it cannot route DNS through that tunnel either.
This creates a bootstrap dependency:
DNS is needed to establish WireGuard → WireGuard is needed to access the DNS.
That is why I think having a DNS option bound directly to an outbound (similar to WireGuard’s DNS setting in wg-quick) would still be useful. The current tag + routing method is good for DNS leak prevention, but it may not cover the case where the DNS itself must be reached through the outbound tunnel.
@harryngne commented on GitHub (Jul 9, 2026):
I agree that the DNS tag + routing rule approach works for routing DNS queries, but there is still a bootstrap issue in a transit setup.
For example, Node A needs to resolve the WireGuard endpoint before the tunnel to Node B can be established. If Node A loses DNS, it cannot bring up the WireGuard outbound, so it cannot send DNS queries through that outbound either.
A complete solution could separate these two cases:
An outbound selector in the DNS server settings would improve the second case, but WireGuard endpoint resolution still needs a fallback mechanism (IP endpoint, cached DNS, or dedicated bootstrap resolver).
@harryngne commented on GitHub (Jul 9, 2026):
The current DNS tag + routing rule method is useful, but for a transit node setup it does not fully solve the DNS dependency problem.
A better design would be to separate DNS into two purposes:
Used by Node A only to resolve the WireGuard endpoint before the tunnel is established. This should remain independent from the tunnel.
After the WireGuard outbound is active, selected DNS queries should be routed through that outbound to Node B.
For usability, 3x-ui could add an optional “Outbound Tag” field in the DNS server settings. Internally it could generate the routing rule automatically.
This would provide:
The bootstrap resolver is still required because a tunnel cannot be used before it exists.