Replies: 11 comments 4 replies
-
To pass DNS requests through the Wireguard outbound, you can configure Xray to intercept DNS traffic and route it through the desired outbound. "outbounds": [
{
"protocol": "freedom",
"tag": "direct"
},
{
"protocol": "freedom",
"settings": {
"domainStrategy": "UseIPv4"
},
"proxySettings": {
"tag": "wireguard"
},
"tag": "warp-IPv4"
},
{
"protocol": "freedom",
"settings": {
"domainStrategy": "UseIPv6"
},
"proxySettings": {
"tag": "wireguard"
},
"tag": "warp-IPv6"
}
],
"routing": {
"rules": [
{
"type": "field",
"port": 53,
"outboundTag": "wireguard"
}
]
} In this configuration, we have defined two Wireguard-related outbounds: Next, we have a routing rule that matches DNS traffic on port 53 and routes it through the By configuring Xray in this way, DNS requests should be passed through the Wireguard outbound, allowing them to be resolved by the Wireguard server rather than the server resolver. This should help prevent DNS leaks and ensure that the DNS resolution location matches the IP location provided by the Wireguard server. |
Beta Was this translation helpful? Give feedback.
-
Hi, thanks for your answer, unfortunately the provided solution didnt work. I edited to this:
But it didn't change client IP to wireguards server IP nor fixed the DNS resolution problem. For second try I just added the routing part to my previous config, but it didnt work again, It was the same:
P.S:
|
Beta Was this translation helpful? Give feedback.
-
Yes, it is possible to pass DNS requests through the Wireguard outbound connection. In the configuration file, there is a specific section for DNS configuration that allows you to intercept and forward DNS queries. By using the appropriate settings, you can ensure that DNS requests are processed through the Wireguard server instead of your server resolver. In your case, if you set Wireguard as the first outbound connection and test for DNS leaks, the DNS resolution should be done by the Wireguard server located in the USA, not your server resolver in Germany. This means that the DNS leak location should match the IP location of the Wireguard server. make sure to configure the routing rules properly so that DNS requests tagged with dns-in are processed through the outbound tagged dns-out. Additionally, check if any specific settings related to non-IP queries (such as A or AAAA records) need to be configured to prevent non-IP DNS traffic from leaking or being processed.
When you use proxySettings, you explicitly specify the outbound tag for traffic forwarding. On the other hand, when you set Wireguard outbound as the first and topmost outbound, all traffic, including DNS requests, will automatically be routed through Wireguard without explicitly specifying the outbound tag. |
Beta Was this translation helpful? Give feedback.
-
{
"tag": "outbound-wireguard",
"protocol": "wireguard",
"settings": {
"mtu": 1280,
"secretKey": "OMpOkugnsUGxa+JnUAoN2DIpnmwCS3kgVZTEmpXcYGE=",
"reserved":[67,145,173],
"peers": [
{
"endpoint": "162.159.192.2:2408",
"publicKey": "bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=",
"allowedIPs": [
"0.0.0.0/0",
"::/0"
]
}
],
"address": [
"172.16.0.2/32",
"2606:4700:110:8301:cd13:e428:aaca:478d/128"
],
"domainStrategy": "ForceIP" // Add this configuration, you can fill in "ForceIP", "ForceIPv6", "ForceIPv4", "ForceIPv6v4", "ForceIPv4v6"
}
} |
Beta Was this translation helpful? Give feedback.
-
Hello again. As you can see, It doesnt work. |
Beta Was this translation helpful? Give feedback.
-
Without seeing the entire configuration, especially the
"inbounds": [
{
"protocol": "dokodemo-door",
"port": 53,
"settings": {
"network": "tcp,udp",
"address": "1.1.1.1",
"port": 53,
"followRedirect": false
},
"tag": "dns-in"
}
] This would capture DNS requests, tagged as
"routing": {
"rules": [
{
"type": "field",
"inboundTag": ["dns-in"],
"outboundTag": "wireguard"
},
// ... other rules
]
} |
Beta Was this translation helpful? Give feedback.
-
Ok, since both of you guys mentioned the inbounds and full config, here is mine:
|
Beta Was this translation helpful? Give feedback.
-
As @us254 has written, it looks like you are not routing DNS packets to your
|
Beta Was this translation helpful? Give feedback.
-
I suspect the answer is to force Xray's built-in DNS server to send its queries through your outbound, something like #1141, but I do not know exactly how you would do that. |
Beta Was this translation helpful? Give feedback.
-
Solution 1: Explicitly route DNS requests through WireGuard:
{
...
"inbounds": [
{
"protocol": "dokodemo-door",
"port": 53,
"tag": "dns-in",
...
},
...
],
...
} This snippet configures a "dokodemo-door" inbound with port 53 and a tag "dns-in". This ensures Xray captures all DNS requests.
{
...
"routing": {
"rules": [
{
"type": "field",
"inboundTag": ["dns-in"],
"outboundTag": "wireguard"
},
...
]
},
...
} This rule specifies that DNS requests tagged as "dns-in" are routed through the "wireguard" outbound.
Solution 2: Use DoH/DoT:
{
...
"dns": {
"tag": "dns",
"servers": [
"https://dns.google/dns-query" // Google DoH
]
},
...
} This uses Google's DoH server (8.8.8.8#853) for DNS resolution. Choose a reliable DoH/DoT provider. |
Beta Was this translation helpful? Give feedback.
-
here https://github.com/atamelo/xray/blob/master/server_config.json is the xray server config that:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
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).
Beta Was this translation helpful? Give feedback.
All reactions