V2ray Custom DNS (Xray)¶
Step 1. Open V2ray Custom DNS tab¶
- In DNS Settings window click the V2ray Custom DNS tab
- Enable Enable Custom DNS toggle (if not already on)
Step 2. Paste configuration¶
Copy the JSON below and paste into the HTTP/SOCKS field:
Xray DNS JSON — click to expand and copy
{
"hosts": {
"dns.quad9.net": [
"9.9.9.9",
"149.112.112.112"
],
"doh.mullvad.net": [
"194.242.2.2"
]
},
"servers": [
{
"address": "https://dns.quad9.net/dns-query",
"queryStrategy": "UseIPv4",
"unexpectedIPs": [
"geoip:private"
],
"skipFallback": false
},
{
"address": "https://doh.mullvad.net/dns-query",
"queryStrategy": "UseIPv4",
"unexpectedIPs": [
"geoip:private"
],
"skipFallback": false
}
],
"queryStrategy": "UseIPv4",
"disableFallback": false,
"disableCache": false,
"serveStale": true,
"serveExpiredTTL": 3600,
"useSystemHosts": false,
"tag": "dns_inbound"
}
Step 3. Set Outbound DNS address¶
- At the bottom, set Outbound DNS address:
dhcp://auto - Click Confirm
dhcp://auto — for direct outbound traffic, Xray uses DNS from your router (DHCP). Direct traffic (Russian sites) resolves locally — faster, no anomalies.
Don't click Confirm yet!
First configure the sing-box Custom DNS tab (next page), then Confirm once — both settings save together.
Parameter explanations¶
hosts block¶
Maps DNS server names to IPs directly — bootstrap that breaks the DNS loop. Without it, Xray would try to resolve dns.quad9.net through itself.
servers block¶
unexpectedIPs: ["geoip:private"] — if a DNS server returns a private IP (192.168.x.x) — treat it as suspicious (likely DNS poisoning by ISP) and try the next server.
Global settings¶
serveStale: true + serveExpiredTTL: 3600 — if a cached DNS entry expires, still serve it (up to 1 hour) while refreshing in background. Critical for stability: a temporary DNS outage won't break your internet.
useSystemHosts: false — don't use the system hosts file. It could be modified by malware.
tag: "dns_inbound" — internal name for the DNS module, used in routing.