[GH-ISSUE #5871] [Feature]: passing dns request throught outbound #4077

Open
opened 2026-10-31 20:36:58 +07:00 by bsakaguchi · 4 comments
Owner

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

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.

Image

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?

  • 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 @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. <img width="660" height="1434" alt="Image" src="https://github.com/user-attachments/assets/72609992-eac1-488e-976f-0025c908cec1" /> ### 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? - [x] 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 (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.

  1. DNS tab (Xray Configs → DNS): add or edit the DNS server you want resolved through the tunnel and set its DNS Inbound Tag (e.g. wg-dns). This is the tag field on DnsServerObjectInnerSchema (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).
  2. Routing tab (Xray Configs → Routing): add a rule with Inbound Tags set to that same tag (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 both inboundTag and outboundTag (frontend/src/pages/xray/routing/RuleFormModal.tsx:286-295).

In Xray-core's DNS subsystem, a server's tag marks 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.ts only defines mtu, 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.md or docs/), 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.

<!-- gh-comment-id:4923456095 --> @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. 1. **DNS tab** (Xray Configs → DNS): add or edit the DNS server you want resolved through the tunnel and set its **DNS Inbound Tag** (e.g. `wg-dns`). This is the `tag` field on `DnsServerObjectInnerSchema` (`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`). 2. **Routing tab** (Xray Configs → Routing): add a rule with **Inbound Tags** set to that same tag (`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 both `inboundTag` and `outboundTag` (`frontend/src/pages/xray/routing/RuleFormModal.tsx:286-295`). In Xray-core's DNS subsystem, a server's `tag` marks 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.ts` only defines `mtu`, `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.md` or `docs/`), 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.*
Author
Owner

@harryngne 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.

DNS tab (Xray Configs → DNS): add or edit the DNS server you want resolved through the tunnel and set its DNS Inbound Tag (e.g. wg-dns). This is the tag field on DnsServerObjectInnerSchema (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).
Routing tab (Xray Configs → Routing): add a rule with Inbound Tags set to that same tag (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 both inboundTag and outboundTag (frontend/src/pages/xray/routing/RuleFormModal.tsx:286-295).
In Xray-core's DNS subsystem, a server's tag marks 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.ts only defines mtu, 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.md or docs/), 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.

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.

<!-- gh-comment-id:4923492270 --> @harryngne 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. > > DNS tab (Xray Configs → DNS): add or edit the DNS server you want resolved through the tunnel and set its DNS Inbound Tag (e.g. wg-dns). This is the tag field on DnsServerObjectInnerSchema (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). > Routing tab (Xray Configs → Routing): add a rule with Inbound Tags set to that same tag (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 both inboundTag and outboundTag (frontend/src/pages/xray/routing/RuleFormModal.tsx:286-295). > In Xray-core's DNS subsystem, a server's tag marks 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.ts only defines mtu, 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.md or docs/), 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. > > 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.
Author
Owner

@harryngne 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.

  1. DNS tab (Xray Configs → DNS): add or edit the DNS server you want resolved through the tunnel and set its DNS Inbound Tag (e.g. wg-dns). This is the tag field on DnsServerObjectInnerSchema (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).
  2. Routing tab (Xray Configs → Routing): add a rule with Inbound Tags set to that same tag (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 both inboundTag and outboundTag (frontend/src/pages/xray/routing/RuleFormModal.tsx:286-295).

In Xray-core's DNS subsystem, a server's tag marks 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.ts only defines mtu, 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.md or docs/), 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.

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:

  1. Bootstrap DNS: used only by Node A to resolve WireGuard endpoints.
  2. Routed DNS: user/client DNS queries that can be forced through the WireGuard outbound.

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).

<!-- gh-comment-id:4923510727 --> @harryngne 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. > > 1. **DNS tab** (Xray Configs → DNS): add or edit the DNS server you want resolved through the tunnel and set its **DNS Inbound Tag** (e.g. `wg-dns`). This is the `tag` field on `DnsServerObjectInnerSchema` (`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`). > 2. **Routing tab** (Xray Configs → Routing): add a rule with **Inbound Tags** set to that same tag (`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 both `inboundTag` and `outboundTag` (`frontend/src/pages/xray/routing/RuleFormModal.tsx:286-295`). > > In Xray-core's DNS subsystem, a server's `tag` marks 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.ts` only defines `mtu`, `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.md` or `docs/`), 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.* 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: 1. Bootstrap DNS: used only by Node A to resolve WireGuard endpoints. 2. Routed DNS: user/client DNS queries that can be forced through the WireGuard outbound. 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).
Author
Owner

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

  1. Bootstrap DNS:
    Used by Node A only to resolve the WireGuard endpoint before the tunnel is established. This should remain independent from the tunnel.
  2. Tunnel DNS:
    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:

  • No DNS leaks
  • No manual routing configuration
  • Support for multi-node transit setups
  • No circular dependency between DNS and WireGuard

The bootstrap resolver is still required because a tunnel cannot be used before it exists.

<!-- gh-comment-id:4923520116 --> @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: 1. Bootstrap DNS: Used by Node A only to resolve the WireGuard endpoint before the tunnel is established. This should remain independent from the tunnel. 2. Tunnel DNS: 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: * No DNS leaks * No manual routing configuration * Support for multi-node transit setups * No circular dependency between DNS and WireGuard The bootstrap resolver is still required because a tunnel cannot be used before it exists.
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#4077
No description provided.