V2Ray DNS Leak Test and Prevention: v2rayN and v2rayNG Setup

Learn what causes DNS leaks and how to test for them, then configure remote DNS, routing, and TUN in v2rayN and v2rayNG to send DNS queries through the proxy.

At a glance

A proxy IP on a test page doesn’t mean DNS queries took the same route. If the test still shows your local ISP’s resolvers, compare results with the proxy disconnected and connected on the same network. Then check which component resolves domains, which outbound handles DNS requests, and whether TUN or Android VPN covers the app you’re testing.

What counts as a DNS leak: DNS queries versus web traffic

When an app visits a domain, it may first ask the operating system to resolve it, then connect to the returned IP. Or it may send the domain through a proxy for resolution by the core or a remote server. With system proxy enabled, apps that honor proxy settings can send web traffic through the client, but this doesn’t necessarily change the route used by the system resolver or apps that ignore proxy settings. A browser’s Secure DNS may also send encrypted queries independently.

Whether this is a leak depends on your routing expectations. If internal domains are supposed to use local DNS, that’s intentional direct routing. If domains meant to go through the proxy are still resolved by your local ISP, the configured policy doesn’t match the actual route. Switching to a public DNS resolver doesn’t guarantee queries go through the proxy; the client may still connect to that resolver directly.

53
Common UDP and TCP ports for traditional DNS
853
Default TCP port for DNS over TLS
443
Common DNS over HTTPS port, also used for regular HTTPS

Bottom line: check both the resolver and the outbound route

To verify that a query takes the expected proxy route, use a test page to identify the recursive resolver, then check the DNS connection’s outbound in the logs from the same test. No visible traffic on port 53 rules out only traditional DNS within the scope of your monitoring; it doesn’t rule out direct connections using encrypted DNS.

How to test for DNS leaks: run three comparisons in the same browser

Test pages typically have your browser request a randomly generated domain, then list the recursive resolvers based on queries received by the authoritative server. The results show how that browser’s queries were resolved during that test—not how every app on your device handles DNS. It’s also normal for the web exit IP and resolver to appear in different locations; public DNS services may respond from nodes in different regions.

  1. Record a direct-connection baseline. Use a regular test domain on the same Wi-Fi network. Temporarily turn off the client proxy or VPN, and quit other tools that change network routing. Open a DNS leak test page and note the web exit IP, resolver name or network, and whether the browser’s Secure DNS is enabled.
  2. Test your usual proxy setup. On desktop, enable your regular system proxy. On Android, use your usual VPN and per-app proxy settings. Keep the node, network, and browser settings unchanged, then start a fresh test. Don’t treat results left over from an earlier test as new queries.
  3. Change one setting at a time. On desktop, switch to TUN and test again if you need to capture more traffic. If you suspect the browser’s Secure DNS, change only that setting and run another comparison. Restore your original settings afterward, or note which settings you’ve decided to keep.

If the web exit IP changes but the resolver is still your direct-connection ISP, first check whether the browser bypasses the proxy or the core routed the query directly. If both tests show the same public DNS service, the test page alone can’t tell whether the query was proxied; check the connection logs too. The same provider can serve requests over two different routes.

v2rayN DNS settings: route DNS through the proxy, then use TUN for broader coverage

These steps use v2rayN with the Xray core as an example. Depending on the desktop version, the menu may be called “DNS Settings” or “Custom DNS Settings,” and routing rules may be grouped differently. Before making changes, note the current core, active routing profile, and DNS settings. If you use a full custom configuration, first check whether DNS settings in the interface apply to it.

  1. Note your current settings

    In the main window, open “Settings” → “Routing Settings” and note the active profile and rule order. Keep the same node, confirm that web traffic works, then record a DNS test result. This helps rule out node issues before troubleshooting DNS.

  2. Configure remote DNS

    Open “Settings” → “DNS Settings” (called “Custom DNS Settings” in some versions) and edit the DNS settings used by the active Xray configuration. If the interface has a remote DNS field, enter a trusted resolver address as instructed. If it requires a complete configuration, edit the existing DNS config—don’t paste a single address into a JSON editor.

  3. Check the proxy outbound

    Go back to “Settings” → “Routing Settings” and check which rule handles connections to the resolver. For DNS connections evaluated by the regular routing rules, place the resolver’s target rule before any direct or catch-all rule that would match first, and assign it a proxy outbound. If the configuration has a separate DNS outbound option, check that instead. After making changes, check the logs to confirm they took effect as expected.

  4. Enable TUN and test again

    If the app you’re testing doesn’t honor the system proxy, turn on “Enable TUN” in the main window. Follow any prompts to grant system permissions. Once the TUN interface is active, rerun the test in the same browser, then test other apps separately. Turning on TUN alone doesn’t guarantee that all DNS is captured; check DNS handling and routing rules for the active core as well.

v2rayNG remote DNS: check which apps are covered by the VPN

v2rayNG uses the Xray core and typically routes traffic for selected apps through Android’s VPN interface. Seeing a VPN icon in the status bar only confirms that a VPN session is active; it doesn’t prove that a particular app is covered or that every DNS query uses remote DNS.

  • Distinguish remote DNS from direct DNS. Open “☰” → “Settings” and find the DNS options. Check “Remote DNS” and “Direct DNS.” If your version has an “Enable local DNS” option, also check whether the core currently handles DNS requests received locally. Save your changes, then disconnect and reconnect so you’re not using the old VPN session.
  • Check per-app proxy settings. Open “☰” → “Settings” and find “Per-app proxy.” Check whether the current mode proxies only selected apps or bypasses them. Include the test browser in VPN coverage before testing. If the browser is deliberately excluded, its results don’t tell you how other covered apps behave.
  • Check the routing profile. Open “☰” → “Settings” and look for “Routing Settings.” If you use a split-routing profile, verify how it handles domains routed through the proxy and those routed directly. Don’t count domains intentionally resolved locally as leaks. After changing the profile, test again with the same node and network.
  • Rule out Android Private DNS. If results still don’t match, search Android settings for “Private DNS” and note the current mode. Then check the browser’s Secure DNS setting. Change only one setting at a time. Restore the original settings after your comparison to avoid weakening DNS encryption for the whole device to fix one app.

DNS changes broke connectivity? Start with the first log entry

Clearly recording what changed is more useful than repeatedly switching resolvers. After reconnecting, look for the earliest error and use its timestamp and destination to distinguish node connections, resolver connections, and local listeners. The examples below may appear in logs; a single error doesn’t prove that a DNS leak occurred.

Error: failed to find an available destination

Cause and fix: This is a general outbound connection failure, not necessarily a DNS issue. Check the nested errors below it. If they mention lookup and the node hostname, restore a working resolution path for the node before testing remote DNS.

Error: context deadline exceeded

Cause and fix: The request didn’t complete before the deadline. If the preceding log entry points to a DNS endpoint, first check its outbound route and protocol. Then retry with a known-working DNS configuration for comparison; don’t just increase the timeout.

Error: bind: address already in use

Cause and fix: The client couldn’t bind to the local address and port shown in the log, so it may not have started handling queries. Close any old instance still using that port, or choose an unused port in the settings. If you manually set the app’s proxy address, update it too.

After testing: browsers, internal domains, and IPv6

The test page passed. Do I need to test other apps?

Yes. Trigger a fresh domain lookup in the app you want to check, confirm it’s covered by TUN or the VPN, and compare the logs for that time. A passing browser test only shows that the browser’s queries in that test didn’t reveal an unexpected resolver.

What if company intranet domains stop working after I enable TUN?

First, revert your latest changes and confirm that the intranet domains resolve on the original network. If they do, route specific internal domain suffixes to the company-designated resolver and keep the routes needed to reach that resolver and internal destinations. Then test internal and public domains separately. Don’t switch all public domains to direct routing.

Does an IPv6 address in the test results mean there’s a leak?

No. First identify whether it’s the resolver’s address, the web connection’s exit IP, or an IPv6 record returned for the domain. If an unexpected resolver appears only on networks with IPv6 enabled, check IPv6 routing in TUN or the VPN and the DNS endpoint’s outbound route, then test again on the same network.

It works after reconnecting, but the problem returns on another network. What should I do?

Record a direct-connection baseline and VPN result on each network. If the issue occurs on only one network, check whether the proxy actually connects there, whether the node hostname can be resolved initially, and whether the system selected a different resolver. When repeating the comparison, keep the node and browser DNS settings the same.

Download v2rayNChoose your platform and installer