Configuration Reference / Advanced Guides

V2Ray Advanced Configuration Guide

Trace configuration, diagnostics, and rollback steps by troubleshooting layer—from subscription source to connection exit.

The Getting Started guide covers your first import, connection, and verification. This guide is for readers with a working configuration who want to look up specific topics. For desktop use, v2rayN is the recommended client; choose an installer for your operating system and architecture from the download center. The JSON examples use Xray configuration syntax. They are not client settings files and are not a universal import format for the two Android clients.

01 / Updates & Filtering

Subscription Groups and Server Filtering

Keep source groups separate from list filters

Group subscriptions by source first, then filter servers by purpose. A source group tells you which URL will update a record; the interface search tells you which records you want to see right now. These serve different purposes. In v2rayN, open Subscription Groups > Subscription Group Settings, add a recognizable note for each source, and make sure each URL is assigned to the right group. Save, select that group, and update its subscription. The interface layout varies by client release and language. If you cannot find a control, use the v2rayN main window guide to identify the server list, group tabs, and log panel.

For the first update, leave filtering off. Open the group and check that the response contains server records—not a sign-in prompt, an error page, or a configuration file for another client. Seeing the protocol, address, and port means the importer recognized the records; transport, encryption, and security settings still need to match the source. Pick a known-working record as a baseline and verify that it can reach an actual service rather than relying on a connection-test number alone. If the update reports success but no records appear, clear the list search, check the selected group and review the update log. Do not reinstall the client before identifying where the failure occurs.

Narrow updates with alias filters

Before enabling server filtering in a subscription group, choose a few real aliases from the unfiltered list that should be kept and excluded. Aliases are usually for display; a name containing a region or purpose does not prove the server's location, exit properties, or protocol capabilities. If the source uses aliases beginning with `Office-` or `Test-` for records to keep, try the regular expression below. It matches only at the start of a line, so the same text appearing in the middle of a name will not count as a prefix. Enter the expression directly in a filter field that supports regular expressions; do not wrap it in slash delimiters.

^(Office|Test)-

After saving, update only the current group and compare the results with the two sample sets you noted earlier. If a record you meant to keep disappears, check whether its name uses full-width punctuation, different spaces, or another hyphen. If the list becomes empty, remove the expression and refresh the group. If it is still empty, check the response, subscription format, and parsing logs. Filtering may run during updates or imports rather than acting as an immediate search, and removing a filter may not restore old records at once. Confirm when your client applies filtering before deciding whether to fetch the subscription again.

Isolate the update, parsing, and connection stages

If an update times out or returns access denied, first check whether the update command is set to make its request through the proxy. It may depend on the active outbound, not the node you are about to import. If a response arrives but parsing fails, check the format provided by the source and whether the client core supports it; changing aliases will not fix a format error. If records import but connections fail, look for the first error in the application log: a server name that cannot be resolved, a failed socket connection, and a failed handshake point to different stages. For common errors and basic settings, see Troubleshooting.

After an update, check the currently selected server again. A matching name does not guarantee the same address, port, or transport parameters; if the source removed the old record, the client may no longer keep it selected. Keep a small number of manually maintained servers separate from source-managed records. Change filters for one group at a time, confirm key records are still present, then save the next set of conditions. If the source changes its naming convention, you can roll back by clearing the filter, refreshing just that group, and restoring known-good records—without affecting other groups.

If the same source shows different records on two devices, compare update times and local filters first, then compare the protocols and transports each client supports. Temporarily narrowing a strict prefix filter to one known record provides a reproducible parsing check. Keep the selected outbound and proxy mode unchanged during testing; otherwise, record visibility and connection behavior change together, making the result hard to interpret.

02 / Matching & Exits

Routing Rules in Practice

Put exceptions before broad matches

Read routing rules from top to bottom as a decision table. Xray selects an outbound when a request matches the first applicable rule; later rules do not override that decision. Before configuring anything, list three requests: an internal service that must connect directly, a test target that should be blocked, and an ordinary request that should use the default exit if no rule matches. Decide which tag each should use before changing the client's routing settings. This helps distinguish a bad rule from the wrong active routing profile. Only the loaded profile takes effect; saving an inactive one will not change how connections behave.

In Xray, routing.rules holds the rules, and outboundTag references a tag defined in outbounds. The example below assumes the configuration already has direct and block outbounds for normal direct connections and rejection. The test domains are for practicing rule matching; they are not a promise that any service will be reachable. Merge the array into the active routing object instead of replacing other rules the client requires. For an overview of the configuration structure, see Understanding the JSON structure of a V2Ray config.

{
  "domainStrategy": "AsIs",
  "rules": [
    {
      "type": "field",
      "domain": ["full:deny.example.test"],
      "outboundTag": "block"
    },
    {
      "type": "field",
      "domain": ["domain:office.example.test"],
      "outboundTag": "direct"
    },
    {
      "type": "field",
      "ip": ["192.168.0.0/16"],
      "outboundTag": "direct"
    }
  ]
}

Check whether a rule matches a domain or an IP address

full: matches an exact, complete domain; domain: matches that domain and its subdomains. A request to a host by name and a request to its raw IP address are different requests and do not necessarily match the same rule. If a proxy inbound receives only the destination address and cannot recover the domain from recognizable application data, there is no domain value to compare. Conversely, with the AsIs strategy, routing does not resolve the destination domain just to match an IP rule; the subnet rule above mainly applies to requests that arrive as addresses.

If your use case requires trying domain rules first and then matching the resolved address against a subnet when nothing matches, consider IPIfNonMatch. It adds a resolution step; it will not fix a misspelled domain or a missing outbound tag. In particular, do not put a catch-all rule at the end of the first pass if you rely on a second pass to match addresses. Once a rule matches in the first pass, there is no “no match, then resolve” step. If unmatched requests should use the first outbound by default, document that outbound's purpose explicitly rather than assuming the last rule acts as a default.

Verify rule order with paired requests

Replace the test domain with a service you control. Keep one request that matches only the exception rule, and prepare a second request that should use the default exit. Before each request, close existing connections or start a fresh client process so connection reuse does not make both measurements share a session. Use available access logs to correlate request times, destination addresses, and selected outbounds. If the logs show the destination but not which rule matched, check connection records on your own test service as well. A page loading successfully alone does not prove that the request used the intended exit.

If a custom rule never takes effect, first confirm that application traffic is actually entering the local proxy, then check that the current profile is applied, the original rule order is intact, and the tags resolve correctly. For geosite: or geoip: rules, also confirm that the running core can find the relevant database and entries. If loading fails, restore the previous routing setup and recheck the baseline with an ordinary request, then test a single full: or explicit subnet rule. Once a minimal rule works, replace it with the category data. This separates matching errors from resource-loading problems.

Distinguish an expected rejection from an outbound failure. When a block rule matches, the test request should not complete; verify that the selected outbound is the rejection outbound. If a normal outbound is selected but access fails, investigate its connection path instead of repeatedly moving the block rule. Keep a copy of the rule order and test cases after each change. Before adding new entries next time, rerun the existing tests, then add the new ones to catch any broad rule that quietly changes established behavior.

03 / Resolution Paths

DNS Configuration

First find out who is making the query

The first step in DNS troubleshooting is not switching to a public resolver; it is finding out whether the application, operating system, or proxy core makes the query. Some applications resolve the target themselves and pass only an address to the proxy. A browser using its own encrypted DNS may also get a different result from the system resolver. The core can apply domain-based rules when a proxy request preserves the domain; whether it then makes a DNS query depends on routing and outbound settings. If you mix up these paths and test the core configuration with a system lookup tool, you may only prove that the system's original path still works.

For troubleshooting, choose a fully qualified domain name you control and note the expected address, the address seen by the application, and the final connection destination. For internal services, also note which network connection is in use and whether enterprise access is enabled; the same name can resolve differently on different networks. Check the fully qualified name first, then see whether a short hostname depends on the system search suffix. If the full name works but the short name does not, check the search domain and how the application makes queries. Do not change the global resolver to fix one application's missing suffix; that could disrupt resolution for other internal domains.

Separate destination routing, resolver selection, and record type

SettingWhat it controlsHow to verify
dns.serversUpstreams available when the core makes a DNS queryChoose a test domain and check a monitored, controlled upstream for the query.
dns.queryStrategyAddress-family policy for core DNS queriesCompare dual-stack and single-stack domains to make sure the policy does not break a required address family.
routing.domainStrategyWhether routing attempts to resolve a domain to an address for matchingTest a target that matches a domain rule and one that requires an address for matching.

This example shows Xray's built-in DNS using a controlled resolver for a specified internal domain, while other queries can use the system resolver. Replace the domain and address with values from your own test environment, and confirm that the core can reach that server. If the internal domain must use a particular upstream, also test what happens when that upstream fails; preferring a resolver for a domain does not guarantee that no other resolver will be queried. This snippet does not take over system DNS or automatically redirect applications that use their own resolver to the core.

{
  "dns": {
    "servers": [
      {
        "address": "192.168.1.53",
        "port": 53,
        "domains": ["domain:office.example.test"]
      },
      "localhost"
    ],
    "queryStrategy": "UseIP"
  }
}

Troubleshoot caches, address families, and startup dependencies

After making a change, test with a new connection and account for caches maintained by the system, browser, core, and upstream. Restarting the client will not clear every cache, and clearing the system cache will not necessarily change the browser's state. For a reliable comparison, use a test name in your own domain that has not been queried before, or wait for the existing record's TTL to expire. If lookup fails, distinguish a timeout, a nonexistent name, and a returned address that cannot be used. For a timeout, check upstream reachability; for a nonexistent name, check for the wrong upstream or a typo; if an address is returned but the connection fails, investigate the connection path.

On dual-stack networks, do not treat “an address of this family was returned” and “that family is reachable” as the same result. Keep dual-stack behavior as your baseline and compare only the link that is actually failing. If the proxy server itself is configured by domain, consider the startup dependency: a new resolution path that relies on an outbound that has not been established yet can create a loop. First verify that the initial lookup needed to start the proxy can use an independently reachable path, then test target lookups after the proxy is running. For encrypted upstreams, check the hostname, certificate validity, and initial resolution requirements. Do not disable certificate verification to test connectivity.

When recording your findings, note who made the query, which resolver received it, and which connection used the result. Put this evidence next to the pre-change baseline; it is more useful than a vague note that “the network is faster.” Test at least one internal service, one ordinary external domain, and the proxy server itself. Testing ordinary domains alone can miss split DNS; testing only the proxy server does not prove that application requests use the expected path.

04 / Traffic Capture

TUN Mode

Prove the same outbound works in normal mode first

TUN changes how application traffic enters the proxy; it does not fix a connection to the server. System proxy settings are used mainly by applications that honor them. TUN uses a virtual network interface and system routes to bring applications that ignore proxy settings into the processing path. The actual capture scope depends on the interface, routes, address family, and client settings. First confirm that the same outbound can reach the target service using v2rayN's normal proxy mode, then enable TUN. If the handshake already fails in normal mode, a virtual interface only adds another layer to troubleshoot.

Before enabling TUN, note the selected routing profile, network interface, and system proxy state. Turn off any other tool that captures the default route, or check with your network administrator before running them together. Then grant the permissions requested by the client to create a virtual interface and change routes, and enable TUN in the interface. Do not rely on the toggle alone: check the startup log for interface creation, permission errors, or failed route updates. If startup fails, stop the attempt and confirm the system can still connect over its original path before making further changes.

Check interfaces and routes, not just the default route

PlatformRead-only checkWhat to look for
WindowsGet-NetRouteIn PowerShell, compare the target prefixes and interface indexes before and after enabling TUN.
macOSnetstat -rnInspect routes associated with the virtual interface and compare them with routes on the original physical interface.
Linuxip rule show、ip route show table allCheck policy rules alongside their associated routing tables; the main table alone is not enough.

Traffic capture may use several more-specific prefixes, so the original default route does not always change. Use a specific test destination to check the prefix, interface, and system policy, and compare the route to the proxy server as well. If the proxy server's own connection is sent back through the virtual interface, traffic can loop and cause multiple targets to time out after TUN starts. Check the client's interface, route exclusions, or handling of its own connections instead of deleting the physical adapter's default route. If the DNS upstream also follows a redirected path, addresses may be reachable while domains fail; return to the DNS section and troubleshoot each layer separately.

Test applications, internal services, and rollback paths separately

Choose an application that does not honor system proxy settings and access the same controlled service before and after enabling TUN. With both the system proxy and TUN enabled, an application may still connect to a local proxy port first, so a page loading in a browser does not prove that the connection went directly through the virtual interface. During testing, make the comparison application send requests explicitly without a proxy and compare the inbound source in the client logs. Test UDP separately for applications that require it; TCP success does not prove UDP works. Check IPv4 and IPv6 separately too—a single successful connection does not show that every protocol stack is captured.

Then test a local network service that should connect directly. If its IP address is unreachable, check the route selected for that destination; if the address works but the name does not, check internal DNS and discovery mechanisms that depend on the local network. If small requests work but larger connections stall repeatedly, note whether the issue occurs only on a particular network, address family, or service, then investigate the path MTU. Save the original interface settings before changing them and make one change at a time. Do not switch outbounds, change DNS, and adjust interface settings simultaneously; even if the problem goes away, you will not know why.

On mobile, traffic capture depends on Android VPN authorization and the client implementation; desktop commands do not apply. If a desktop issue appears only after waking from sleep, switching Wi-Fi networks, or plugging in a cable, include that transition in your tests. Success on a static network confirms only that the initial routes were correct. For more, see How v2rayN TUN works and how to verify it, and compare its setup steps with your current interface.

05 / Address-to-Domain Mapping

FakeDNS

Make sure queries and subsequent connections use the same mapping

FakeDNS does not speed up upstream DNS; it addresses the loss of a domain name before a connection reaches the proxy. When an application queries a domain, the resolver handling the request returns a synthetic address from a reserved pool and records the address-to-domain mapping. The application then connects to that address, and the receiving proxy uses the mapping to recover the original domain and apply domain-based rules. Both conditions must hold: the application receives an address assigned by this configuration, and the subsequent connection reaches an inbound that understands the mapping. A regular static host mapping returns an address but cannot complete this processing chain on its own.

First identify which component owns the configuration. The example below shows the parts of Xray's built-in FakeDNS configuration; it is not the syntax for a TUN backend or another core. If the client's TUN backend already assigns synthetic addresses, do not copy the same address pool into Xray without checking first. Independently managed mappings do not necessarily associate the same address with the same domain, even if the pools share a prefix. Confirm which component answers the query, receives the connection, and holds the active mapping before choosing where to enable FakeDNS. If you cannot control all three, stick with the existing real-address resolution path.

Verify the full loop on a domain you control

The example sends queries for lab.example.test to fakedns first and lets other queries use the system resolver. Replace the example domain with one you control and that has a real upstream record. The synthetic address pool must not overlap with local routes or address ranges used by other traffic-capture tools. In this snippet, dns and fakedns are top-level configuration sections. A separate requirement is that the application's DNS queries actually reach this built-in resolver; adding the snippet alone does not redirect system queries.

{
  "dns": {
    "servers": [
      {
        "address": "fakedns",
        "domains": ["domain:lab.example.test"],
        "skipFallback": true
      },
      "localhost"
    ]
  },
  "fakedns": [
    {
      "ipPool": "198.18.0.0/15",
      "poolSize": 65535
    }
  ]
}

The Xray inbound that receives connections to synthetic addresses must also enable sniffing and include "fakedns" in destOverride. The goal is to restore the domain used for the connection, not merely to retrieve a domain for routing, so do not set this inbound to the routing-only routeOnly: true mode. Keep the inbound's other required settings, regenerate or reload the configuration, and verify what is active. Then make a fresh lookup and application connection. Confirm all four steps: the response is in the pool, the connection reaches this inbound, the core recovers the original domain, and the final outbound connects to the real destination.

Keep synthetic addresses from reaching the wrong outbound

If an application receives an address from the pool but cannot connect, first check whether it bypassed the capture interface—especially if there are per-app exclusions or direct rules for the address range. If the connection reaches the core but still goes out using the synthetic address, check the sniffing settings on that inbound and whether the mapping is still available. Also verify how the final outbound resolves the real domain: if it uses the same resolver that returns synthetic addresses, the recovered domain may be turned back into an internal address. Test “return a synthetic answer to the application” separately from “resolve the real address for the final connection.”

Mappings are not permanent. An application may retain an old response, the core may restart, or an address-pool entry may be evicted, leaving a cached synthetic address without its original meaning. For intermittent failures, note whether any component restarted between the query and connection, then make the application resolve the name again and create a new connection. Programs that connect directly to raw IP addresses have no domain query to map; applications using their own encrypted resolver may bypass this path too. Leave internal service discovery, admin pages, and applications that require real addresses on normal resolution unless targeted tests show otherwise. Do not use global enablement as a substitute for those tests.

If a single controlled domain works, do not immediately expand FakeDNS to all traffic. Add a comparison domain that continues to receive a real answer and confirm that the normal path is unchanged. Also verify that it still works with traffic capture turned off. Limiting the scope makes it possible to compare where each type of request departs from expectations, instead of sending every domain through an address mapping that is difficult to observe.

06 / Sources & Maintenance

Managing Multiple Subscriptions

Use one group for each update boundary

The key to managing multiple subscriptions is being able to update, disable, and restore each source independently. If one source provides URLs in different formats, do not treat them as the same configuration; check which format the target client can import and what each URL is for before deciding what to keep. Add the source's purpose and configuration context to each group note, such as “Office backup” or “Mobile testing,” rather than putting access URLs or full identity details there. When something goes wrong, work only on the affected group. Leave groups that still work untouched so they remain a point of comparison if multiple sources change at once.

Keep a brief maintenance record for each group: its purpose, whether it updates automatically, the result of its last successful verification, and enough detail to identify important records. Record only what you need to find them again; there is no need to copy every parameter. Do not delete duplicates based on names alone. The same alias can appear in two groups, and even identical addresses and ports may have different identities, transports, or security settings. Decide which source and connection configuration you want to keep before deduplicating. If the list is simply too long, use group views or search rather than editing subscription contents.

Keep the startup outbound independent of the source being updated

If a group's update request must use an existing proxy, make sure it does not depend on the group's only working record. Before updating, switch to a different verified connection that is outside the refresh scope. Then verify the new records in the target group on their own before making one your everyday choice. If an update fails, determine whether the request was never sent locally, the outbound could not reach the source, or the source returned an authentication or rate-limit message. Also check whether the update command uses the proxy; changing servers may have no effect on an update sent directly.

A refresh can change the local set of records even when parsing succeeds. If the source removes records, renames them, or changes formats, an old record you planned to keep may disappear. Back up any configuration you need to retain using a method supported by the client, and confirm that restoring it will not leave it subject to the same subscription's updates. Frequent automatic updates are not a fix for occasional disconnects: when a source is changing its records, refreshing too often makes it harder to compare states. If the client supports automatic updates per group, set them according to each source's recommendations and how often you use it. If updates are all-or-nothing, keep a manual review process for critical groups.

Use sources for cross-device sync and backups for recovery

Desktop v2rayN and Android clients v2rayNG and v2flyNG can each import subscriptions supported by their own core. Sharing a source syncs server details; it does not sync filters, routing, active selections, or system traffic-capture settings across clients. When migrating, import and verify one known record on the destination device, then align local settings one at a time. If same-named nodes appear on both devices but only one connects, compare the actual protocol, transport, and security parameters, then check core support on each device. Do not overwrite a device that still works just to make the lists match.

Sharing a single node is useful for temporarily moving one record, but does not replace automatic subscription updates. Backups are useful for recovery or migration between similar clients, but are not a cross-platform configuration standard. For a comparison of these methods, see Syncing V2Ray settings between desktop and mobile. Before restoring a backup, account for differences in the destination device's network and permissions, then check whether routing or DNS settings still reference an old interface, path, or missing outbound. Backups may contain subscription and authentication details; keep them in a controlled location and do not share them with ordinary screenshots or error reports.

To verify multiple subscriptions, run a one-time update on a noncritical group. Make sure the other group lists remain unchanged, and check whether the client switched the active connection. Repeat the same test on another device, but do not refresh both devices at once; keep one as a working reference. A successful result means the group belongs to the right source, its important records work, and it can be restored if something fails. Similar record counts alone do not prove that subscriptions stayed in their intended groups.

07 / Tags & Connections

Custom Outbounds

Decide whether to change routing or add an outbound

A custom outbound defines the protocol and connection parameters the core uses to send traffic; routing decides which outbound to use. If an existing outbound is suitable and you only need different destinations to take different paths, changing the rules is enough. Add an outbound when you need to connect another local proxy, change direct-connection behavior, or test connection parameters separately. Give the new outbound its own tag; do not reuse the tag of the current default outbound. Keep the existing default outbound order and start with one narrowly scoped rule that references the new tag. Expand its use only after verification.

Graphical clients typically generate their runtime configuration from the selected server, inbound settings, and routing profile. Direct edits to a generated file may be overwritten when you switch records, apply settings, or restart. Check whether your current workflow supports custom configuration and whether the client creates additional local listening ports. If you need full control, use a custom configuration entry point supported by the client in a controlled environment. Do not paste core configuration into a subscription URL or a general settings form. Protocols and fields vary by core; for help choosing one, see Xray-core vs. V2Fly core.

Test one explicit forwarding path with a dedicated inbound

This is a complete, standalone Xray test configuration. It listens on loopback port 11080 and forwards traffic received by that inbound to a SOCKS service running locally on port 11081. You must provide the upstream service in your test environment; the example assumes it requires no authentication and allows the relevant TCP requests. You can change either port, but do not reuse a port already listened to by the client, and do not point the upstream back to this test inbound. Temporarily set the test application's SOCKS address to 127.0.0.1:11080; leave the main application on its existing configuration.

{
  "log": {
    "loglevel": "warning"
  },
  "inbounds": [
    {
      "tag": "lab-in",
      "listen": "127.0.0.1",
      "port": 11080,
      "protocol": "socks",
      "settings": { "auth": "noauth", "udp": false }
    }
  ],
  "outbounds": [
    {
      "tag": "direct",
      "protocol": "freedom"
    },
    {
      "tag": "lab-socks",
      "protocol": "socks",
      "settings": {
        "servers": [
          { "address": "127.0.0.1", "port": 11081 }
        ]
      }
    }
  ],
  "routing": {
    "rules": [
      {
        "type": "field",
        "inboundTag": ["lab-in"],
        "outboundTag": "lab-socks"
      }
    ]
  }
}

First, connect the test application directly to the upstream port and confirm that it can reach a controlled target service. Then point the application at the test inbound and repeat the same request. Look for it in the upstream logs to confirm that it was forwarded rather than accidentally using the first outbound. Next, stop the upstream and repeat the test with a new connection; requests matching this rule should fail instead of falling back to direct. This negative test can reveal a rule that did not match or an application bypassing the proxy. Restart the upstream and test once more to confirm that recovery uses the expected path, not a reused session.

Roll back by checking the listener, selection, and connection stages

If loading fails, check configuration parsing and listener errors first, including JSON structure, protocol names, tag spelling, and port conflicts. If the configuration loads but the upstream sees no connection, check that the application selected the right proxy type, that requests actually reach the test inbound, and that inboundTag references its real tag. If the upstream receives the connection but cannot reach the target, investigate how the upstream resolves the destination and selects its outbound; changing the local inbound repeatedly will not fix an upstream problem. For UDP, verify support on both the inbound and upstream separately: this example intentionally tests TCP only and says nothing about UDP.

Before adding a verified outbound to your everyday profile, confirm that it will not loop through TUN's own-connection exclusions, and do not expose a loopback listener on every interface just for convenience. Verify that existing requests still work after the routing change and that only the intended new requests use the new outbound. To roll back, remove rules that reference the new tag first, verify the original traffic, then remove the new outbound and test inbound. Keep a copy of the last loadable profile and the test target, entry point, and expected outbound. Reuse those test cases when changing outbound parameters again to tell a configuration change from an unreachable target.