Advanced Configuration · Desktop Reference

Advanced V2Ray Configuration Guide

For adding your first node, choosing a proxy mode, or checking your connection, start with the Quick Start Guide. This guide assumes your connection is already working and explains each layer in turn: subscription sources, traffic routing, DNS resolution, and outbound selection. For desktop, we recommend v2rayN. The JSON examples below use Xray and are not universal settings you can paste into any client.

01Import and Filter

Subscription Groups and Server Filtering

Group by source, not by node remarks

Subscription groups answer one basic question: which URL maintains the nodes in a list? In v2rayN, open subscription group management and create a separate entry for each subscription. Name each group by its source or purpose, then enter the subscription URL in the matching group. Choose names that still make sense after the nodes change, such as “Daily” or “Test Source,” rather than naming a group after the current node’s city or protocol. Switch to the group, update that group only, and check that its list comes from the expected source before setting an update schedule. Keep manually added nodes in a separate group instead of mixing them with entries that refresh regularly.

Groups organize candidate nodes; they do not decide which outbound a site uses. After switching groups in the list, check whether the active selection has changed. Seeing another group’s nodes does not mean one of them is in use. Likewise, a routing rule set to proxy will not rotate automatically between subscription groups. Rules match outbound tags in the running configuration; the client’s generated configuration determines which node a tag points to. Debug the rules with the same node first, then switch nodes and test connectivity to identify which layer introduces any difference.

Distinguish list search from update-time filtering

List search usually changes only what you see; server filtering during an update changes which candidates the group retains. When organizing a new source, start without filters and inspect a few full node remarks. Then decide which field to use and whether to filter by keyword or regular expression. If your client’s filter explicitly uses regular expressions and keeps entries whose names match, the example below matches names beginning with Tokyo- or Osaka-. This is not a subscription URL parameter. Don’t use it as-is if the interface excludes matches or accepts plain keywords only.

^(?:Tokyo|Osaka)-

Before enabling the filter, test it against one remark that should match and one that should not. For example, “Tokyo-Main” should match, while “Backup-Tokyo” should not. Full-width and standard hyphens are different characters. A broad condition is less likely to filter everything out, but may keep informational entries too. Locking the filter to an exact number, date, and city name can make the entire group empty when the source changes its naming. A safer approach is to rely only on a prefix the source uses consistently, and keep the condition simple enough to explain why an entry matches.

If you want to keep nodes that use a particular protocol, check the protocol field shown after import instead of guessing from the remark. A protocol name in a node’s label does not guarantee that its parameters use that protocol. Server filtering also generally does not test connectivity: a matching node may still fail because the core does not support its transport parameters, the server is unavailable, or authentication has expired. Rule out selection and field errors first, then make a real request to the same destination. Don’t change the filter based on a single latency test and turn a temporary network issue into a permanent condition.

If an update leaves the group empty, protect your working configuration first

If an update leaves the group empty, clear the search field first to make sure you’re viewing the full list. Then check the update status to distinguish a failure to retrieve the subscription, content that could not be parsed, and entries all removed by the filter. If you still have a working active node, keep another verified configuration available as a fallback. Clear the filter and retry this group only, rather than refreshing every group. If the list is still empty with no filter, check that the URL belongs to this group, is still valid, and returns a format the client supports. Repeated restarts are no substitute for checking these details.

When you’re done, note the group name, update method, filter field, and one representative remark. Don’t include subscription URLs in screenshots or troubleshooting notes; a subscription link may contain access credentials. Record only where the failure occurred. If the source changes its naming scheme, test the filter against the current group before restoring scheduled updates. For nodes that need manual edits, save a separate local entry and note which changes a source update might overwrite. That way, you can compare against the original values instead of relying on memory.

02Route Requests

V2Ray Routing Rules in Practice

Choose the outbound before writing match conditions

Each rule has two parts: check whether a request matches, then choose an outbound for it. First inspect the tags in the running configuration, such as direct for direct connections, proxy for proxy traffic, and block to reject requests. These names are defined in the configuration; they are not reserved words. A mistyped tag does not mean traffic will go direct. In a graphical client, use its routing editor to set and apply rules rather than editing temporary files that may be regenerated on restart or node change. With a custom configuration, check both routing and outbounds.

Rules are checked in array order, and the first matching rule determines the outbound. Multiple alternatives in the same field usually mean any one of them can match. But if a rule specifies both a domain and a port, both conditions must match; they are not alternatives. To send an admin site direct and a test suffix through the proxy, put the exact admin-site rule before the suffix rule. If the suffix rule takes the request first, later exact rules won’t be checked. Testing two exceptions against one ordinary request makes priority errors easier to spot than importing a large batch of rules at once.

This snippet assumes all three tags are defined. The .example names in the three domain rules are for local testing only. Replace them with test domains you control and have configured to resolve before testing real requests. The final rule covers TCP and UDP requests handled by this routing configuration. Without it, Xray usually uses the first outbound when no rule matches, so changing outbound order can also change the default behavior.

{
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {"type": "field", "domain": ["full:admin.lab.example"], "outboundTag": "direct"},
      {"type": "field", "domain": ["full:deny.lab.example"], "outboundTag": "block"},
      {"type": "field", "domain": ["domain:lab.example"], "outboundTag": "proxy"},
      {"type": "field", "ip": ["192.168.0.0/16"], "outboundTag": "direct"},
      {"type": "field", "network": "tcp,udp", "outboundTag": "proxy"}
    ]
  }
}

Distinguish domain rules, IP rules, and resolution strategies

full: matches a complete domain name; domain: matches the domain itself and its subdomains. Neither matches just because a string looks similar. Use a regular expression only when the first two options cannot express the condition, and consider boundaries and unintended matches first. Private IPs can be specified as CIDR ranges. If you use geoip:private or add a geosite: condition, make sure the core’s loaded data files actually contain the category. The same category name may cover different ranges in different data files. Retest any exceptions that depend on these categories after updating the data.

AsIs does not resolve domains just to match IP-based rules. In the example above, if an application passes a domain to the core, the private-IP rule won’t match merely because that domain resolves to a private address. IPIfNonMatch tries to resolve the domain and match again only if no rule matched initially. Don’t expect this second check if a catch-all rule has already handled the request. IPOnDemand resolves as needed when a rule requires an address, which can add a DNS dependency. Before switching strategies, identify which traffic really needs to be matched by its resolved IP. For more prefix and order examples, see Routing Rule Syntax and Priority.

Use the same destination to isolate entry-point and rule issues

To test, make a new connection to an admin domain, a regular subdomain, and a blocked domain. Then compare the results with the numeric IP address of one of those destinations. When an application sends a domain to the core for proxying, that is different from resolving it first and sending only the IP address. Don’t assume an IP-only request will match a domain rule. Whether sniffing can recover the domain depends on the inbound settings, application protocol, and whether the connection provides recognizable information. Sniffing is not a universal fix for every application.

If the log shows an inbound request but the wrong outbound tag, check whether the logged destination is a domain or an IP address, then look for an earlier, broader rule. If the tag is correct but the connection fails, check DNS resolution, the destination port, or the upstream node. After changing the configuration, establish a new connection; existing long-lived connections won’t be rerouted automatically. If the log doesn’t show an inbound request at all, check whether traffic is reaching the core through the system proxy or TUN before changing rule order. Change one thing at a time so you can revert to the last working configuration if something breaks.

03DNS Resolution

Optimize DNS Settings

Identify which component is actually sending the query

Being able to configure DNS in the core does not mean all system and application queries use that resolver. With a system proxy, an application may resolve through the system, pass the domain straight to the proxy, or use its own encrypted DNS. A mode that captures system traffic may add a separate DNS layer in the client. If one application works and another does not, use the same domain and network access method to determine which layer each application uses for resolution. Adding more addresses to the core blindly usually won’t fix queries that bypass it.

Also distinguish two commonly confused settings: routing.domainStrategy determines whether routing resolves addresses to match rules; dns.queryStrategy determines which address families the core uses for DNS queries. Some outbounds have their own target-domain handling strategy, so neither field is a global address-family switch for every connection. When testing a site, record separately whether you received a DNS record and whether you could connect to the address it returned. A successful lookup does not mean your system has a working route to that address.

Configure specific domains separately from the default resolver

If your local network has a private DNS zone, first route queries for that zone only to a resolver that knows it, while keeping a regular resolver for other queries. The snippet below shows Xray’s dns configuration. Replace the example address with a server that is reachable on your current network and can resolve the target zone. Keep localhost only if the system’s default resolver operates independently of the core. When merging this into a custom configuration, keep only one dns object at that level; don’t paste two objects one after another. For graphical settings, follow the field descriptions and check the generated configuration.

{
  "dns": {
    "servers": [
      {
        "address": "192.168.1.1",
        "port": 53,
        "domains": ["domain:lab.example"],
        "skipFallback": true
      },
      "localhost"
    ],
    "disableFallbackIfMatch": true
  }
}

Here, skipFallback prevents the dedicated server from becoming a fallback for other domains; it does not disable all fallback. disableFallbackIfMatch prevents queries that match the dedicated condition from switching to regular candidates. If the dedicated server is unreachable, this configuration will fail DNS resolution more clearly. If you need a second resolver as a backup, add it as a candidate for that zone and confirm it returns the same records. Don’t let unknown zones fall through to a public resolver indiscriminately: an incorrect response may be cached by the application or system.

Encrypted DNS and split DNS are not the same thing. When using a resolver identified by a hostname, that hostname must be resolved first. If resolving it depends on the same connection that has not yet been established, you have a loop. The proxy node’s hostname can be part of the same dependency chain: the node must be resolved to establish the proxy, but DNS traffic is being sent through that proxy. Map the initial resolution path before adding encryption, and keep an independently working initial resolver during migration. Replacing the resolver hostname with an IP does not always solve the problem; the server may still require its hostname for authentication.

Test timeouts separately from error responses

Start by querying a known name that should have a record, then one that definitely does not exist. If the first returns no record quickly, check whether the query went to a resolver that knows the zone. If both time out, first check the upstream address, port, and whether the outbound carrying the query is reachable. System tools only test the resolution path they use themselves. For example, a command that specifies a server tests only that server; it doesn’t prove the application queried it. Repeat the request in the actual application and compare it with the core logs.

nslookup admin.lab.example 192.168.1.1

If failures occur intermittently only on a dual-stack network, compare both address record types for the same name with the actual connection results. Don’t permanently disable an address family just because a request timed out. Keep the original configuration and temporarily retest with a single address family. If the issue disappears, continue checking local routes and upstream connectivity. After changing DNS, account for separate system, application, and core caches. Compare using a new connection or a test name you haven’t queried before, then decide whether a specific cache needs clearing. Don’t enable FakeDNS at the same time; it may return synthetic addresses that can’t be assessed using the original criteria.

04System Traffic Entry

TUN Mode and System Routes

Establish a baseline before switching from system proxy to TUN

Applications use a system proxy when they honor the proxy settings. TUN uses a virtual interface and system routes to send matching network packets to the client. It can cover some applications that ignore system proxy settings, but it does not guarantee that every interface, address family, and protocol will be captured. Bringing up the virtual interface is only the first step: the system still has to route the target traffic through it. Once traffic enters, the core’s routing and outbound support also matter. Choose a mode based on which applications actually need proxy access, rather than enabling both and guessing which one is in effect.

Before switching, record three baselines in system proxy mode: whether a proxied request succeeds, whether a local network destination expected to go direct is reachable, and which addresses currently resolve. If the client treats the two entry methods as separate options, temporarily turn off the system proxy and check that apps such as your browser aren’t configured to use a separate proxy. This gives you a clear TUN test path. After enabling TUN, first retry a request that already worked, then test an application that ignores system proxy settings. If you change the node, DNS, and routing mode at the same time, any of those changes could explain the result, making the baseline useless.

Check the interface, permissions, and routes for your platform

On desktop, start with the v2rayN package for your platform. TUN controls, privilege requirements, and log locations depend on the client and operating system. Don’t elevate every process just to turn on a setting. Check whether the client reports an interface creation or route installation error, then verify the system state. On mobile, traffic capture is controlled by the relevant client and system permissions; desktop commands do not apply. For help choosing a client, see the mobile platform guide on the client downloads page.

Use the system routing table to check whether traffic can reach the virtual interface
PlatformCommandWhat to check
Windowsroute printInterface list, destination networks, next hops, and metrics
macOSnetstat -rnDestination networks, gateways, and their associated interfaces
Linuxip route、ip ruleDestination routes and policy rules; check other route tables referenced by rules if needed

Don’t just count default routes. Some implementations use more specific networks to override the default route; others use policy rules to select different routing tables. Check one specific failing destination and confirm which system route it ultimately uses. Also verify that the proxy node and any DNS resolver that should connect directly can still reach their destinations through the expected physical interface. If the client’s own upstream connection loops back into the virtual interface, traffic may be captured repeatedly. First check the client’s upstream bypass or interface-binding settings; don’t start by excluding all private networks or every connection on a particular port.

Narrow down the cause one failure at a time

If enabling TUN immediately cuts off the network, restore the previous mode, then enable TUN by itself. Check whether the virtual interface comes up and whether the default and upstream routes remain available. If the local network is unreachable but the public internet works, check the network’s actual subnet and whether it overlaps the virtual address pool. A system-level bypass prevents packets from entering TUN; direct in core routing sends them direct after they enter. These are different layers and produce different logs. Exclude traffic at the system entry point only when it genuinely should not be handled by the core.

If regular websites work but a particular real-time app fails, first determine whether the problem is DNS resolution or transport. Then check whether it needs UDP and whether the current outbound supports it. If small requests work but large responses stall, consider path MTU as something to test. Compare the same destination over the same connection; don’t set a fixed value based on a timeout in one app. After changing an interface setting, start a new connection and verify that the test traffic uses the same entry point.

05Domains and Synthetic Addresses

FakeDNS Address Pools and Mapping Recovery

Understand what synthetic addresses are for

FakeDNS returns a synthetic address from its pool in response to a query and records the mapping between that address and the original domain. When the application later connects to the address, the component handling the connection needs access to the same mapping to recover the domain and use it for routing and outbound selection. A synthetic address is not a new address for the destination server or a result to reuse indefinitely from a regular DNS cache. If the application gets a synthetic address but the connection leaves the device through a different path, or the mapping-recovery component has restarted, the lookup may succeed while the connection fails.

Whether to use FakeDNS depends on whether you can control both the query and the subsequent connection, not on how many resolvers are listed. With only a system proxy, an application that already passes domains to the proxy often has no need for synthetic addresses. But when you need to recover a domain from packets that contain only an IP address, and the entry point can capture both the lookup and connection, FakeDNS can give domain rules a chance to match. Enabling synthetic responses without a working recovery path is the most common break in this setup.

Treat the address pool, resolution, and recovery as one change

This top-level Xray snippet shows how an IPv4 address pool relates to the built-in DNS. It does not create a virtual interface or automatically capture system DNS. First confirm that your device, virtual network, and destination networks do not use this address range, then work out how to merge it with your existing DNS configuration. poolSize is the mapping capacity of the pool, not the number of nodes available to the client, and it does not need to equal the address block’s full capacity. Set the capacity with actual concurrent domain lookups and application cache lifetimes in mind.

{
  "fakedns": [
    {"ipPool": "198.18.0.0/15", "poolSize": 4096}
  ],
  "dns": {
    "servers": ["fakedns"],
    "queryStrategy": "UseIPv4"
  }
}

If a compatible Xray inbound handles subsequent connections, enable inbound sniffing and include fakedns in destOverride to recover the destination from the mapping. Merge the example below into the relevant existing inbound object; it is not pasted in the same place as the top-level snippet above. If the client’s own component generates TUN and DNS settings, use that component’s settings. Adding a field with the same name to Xray won’t take over that layer. Checking the active configuration is more reliable than looking at a toggle in the interface.

{
  "sniffing": {
    "enabled": true,
    "destOverride": ["fakedns"]
  }
}

This example covers only the IPv4 synthetic-address path. To extend it to a dual-stack environment, consider the address pool, system routes, and which record type the application chooses together. Enabling queries for another address family alone does not complete traffic capture. Design a real-resolution path for internal services that require real addresses, initial proxy-node resolution, and applications that need to match by IP. Decide whether specific domains should use real DNS before returning records; adding a direct rule to the core won’t fix a synthetic address already cached by an application.

Verify the full flow with a new lookup and connection

Choose a test domain you control. First confirm that the lookup returns an address from the pool, then use the same application that received the response to make a new request. Check the logs for the connection and confirm that the recovered destination is the expected domain. If you see a pool address but no inbound request, the problem is in the system route or traffic capture. If the request reaches the inbound but the log still shows only the synthetic address, check the recovery-enabled inbound, when the cache entry was created, and whether another instance generated the mapping. Once the destination is recovered and the outbound tag is correct, check upstream DNS or connectivity to the real destination.

If only old tabs fail after a restart while new requests work, first suspect that the application is reusing a response obtained before the restart. Quit the relevant application and retest with a new name; don’t expand the pool right away. If the issue started after connecting to another network, check for overlapping subnets and whether real DNS is reachable. Revert the configuration in matching steps: stop returning synthetic addresses, restore regular DNS, and account for applications still holding old answers. Removing connection capture while continuing to issue synthetic addresses creates new failures.

06Updates and Device Migration

Managing Multiple Subscriptions and Syncing Configurations

Track source, purpose, and active status separately

For one subscription, filtering is the main concern. With multiple subscriptions, the priority is managing independent update boundaries. Give each source a fixed group name and record its purpose and the device that updates it. Don’t use node remarks as a substitute for identifying the source. Even if two sources show a node with the same name, they may use different ports, transports, or authentication settings, so don’t merge them based on the name alone. If a source changes its URL, update that group separately and check whether its nodes work with the current core. Deal with the old group or change the active node only after the new group provides a stable connection.

Keep a candidate that recently completed a real request, and know how to switch back to it manually. A subscription refresh doesn’t guarantee that the active entry will keep the same identity, nor does it provide automatic failover. During routing tests, a background refresh may also change the available nodes mid-test. When comparing two policies, pause scheduled updates for the relevant groups and test one node at a time, then restore the regular schedule. For routine updates, refresh one group first and verify requests work before updating the others. This keeps any issue isolated to a known source.

Distinguish syncing nodes from copying the entire runtime environment

Before moving to another device, decide what needs to be synced. A subscription URL lets each device fetch nodes independently; it does not automatically sync local DNS, system proxy ports, routing exceptions, or TUN settings. Sharing a node is generally suitable for moving one selected configuration, not an entire subscription group and its update rules. The range of local settings a client can export depends on the feature and format used. Before migrating, list the routing, DNS, and entry-point settings you need to retain, then verify each one on the destination device. A successful import does not mean the entire configuration is active.

Use v2rayN on desktop. On mobile, choose v2rayNG or v2flyNG based on the core required by the configuration. Even when a node imports successfully, check its transport settings, data files, and custom configuration fields separately. For example, a private DNS resolver available on a desktop network may not be reachable from another network. A virtual subnet used only on the desktop should not be copied straight to a mobile device. On the destination, first test one node in regular connection mode, then add routing and DNS one at a time, and check whether system traffic capture is needed last. For a comparison of migration options, see Configuration Sync Across Multiple Devices.

If you need to share troubleshooting details, include the source group, core family, failure stage, and whether the issue is reproducible. Don’t send a QR code or configuration export containing a subscription URL. Node remarks may also contain account identifiers, so there’s no need to include a screenshot of the full list. Keep configuration exports for recovery in a controlled location, separate from examples used only to explain routing syntax. When retiring an old device, revoke access using the method provided by the source. Removing the subscription from a client does not invalidate a URL that has already been copied.

Plan the smallest rollback for update failures

If only one group times out during an update, first check whether it needs a proxy to fetch the subscription. Then confirm that the currently selected node used for the update can still connect. A client may fetch subscriptions over a different path from application requests. Use the update method offered by the current interface and identify whether the failure occurred before the content was retrieved or after parsing. If updates fail but existing nodes still work, keep them as candidates. If refreshing depends on a node in the same group that has already failed, use an independent working update path instead of deleting the group and repeatedly importing the same URL.

If several sources fail at once, first check what they share: system time, current network, DNS path, and whether the client sends all subscription updates through the same proxy. If only some nodes fail to import, compare the returned format with the configuration fields supported by the core; don’t assume every source is unavailable. After recovery, check each group in order: confirm its entries updated, verify the selected node belongs to the expected source, then make a real request. Separating these steps avoids mistaking a restored list for a working connection when the client is still using an old connection or the wrong node.

07Outbounds and Configuration Boundaries

Xray Custom Outbounds

The outbound protocol defines the action; the tag is how rules refer to it

An outbound object defines how a matched request leaves the core. Use freedom for direct connections, blackhole to drop selected requests, or socks to send traffic to a specifically configured upstream. The tag is only a reference. Naming a tag direct does not make it connect directly; check the object’s protocol and settings. Adding an outbound also doesn’t make it receive particular requests automatically. A routing rule must reference it, or you need to understand the effect of making it the default outbound.

Keep a client-generated configuration that works, and debug custom settings separately rather than repeatedly overwriting temporary runtime files. Give every outbound a unique, stable tag. If you rename one, check all its rule references. Also distinguish inboundTag from outboundTag: the former can identify where a request entered; the latter identifies where a matched request is sent. Check for earlier matching rules too. Before switching cores, read Xray and V2Fly Configuration Compatibility; don’t assume that identically named fields have exactly the same runtime requirements in both.

Build a standalone test configuration on loopback ports

Here’s a complete Xray test configuration. A local application sends SOCKS requests to 127.0.0.1:10880. A separate local SOCKS service already running at 127.0.0.1:10881 handles domains with a specified suffix; blocked domains match a separate rule, and all other requests use the first-listed direct outbound. Both ports are on this device. Before testing, make sure the inbound port is free, the upstream port is listening and accepts connections without authentication, and the upstream won’t connect back to the test inbound. This configuration is intended for TCP testing, not for verifying UDP support.

{
  "log": {"loglevel": "warning"},
  "inbounds": [
    {
      "tag": "test-in",
      "listen": "127.0.0.1",
      "port": 10880,
      "protocol": "socks",
      "settings": {"auth": "noauth", "udp": false}
    }
  ],
  "outbounds": [
    {"tag": "direct", "protocol": "freedom", "settings": {}},
    {"tag": "block", "protocol": "blackhole", "settings": {}},
    {
      "tag": "lab-upstream",
      "protocol": "socks",
      "settings": {
        "servers": [{"address": "127.0.0.1", "port": 10881}]
      }
    }
  ],
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "inboundTag": ["test-in"],
        "domain": ["full:deny.lab.example"],
        "outboundTag": "block"
      },
      {
        "type": "field",
        "inboundTag": ["test-in"],
        "domain": ["domain:lab.example"],
        "outboundTag": "lab-upstream"
      }
    ]
  }
}

Replace the test domain with a resolvable name in an environment you control, and configure the test application to send the domain—not a previously resolved IP address—to SOCKS. Three requests to the same suffix won’t prove three different paths. Instead, request a name that should be blocked by the exact-match rule, a subdomain that should go through the upstream, and a direct destination outside the suffix. For the upstream path, briefly stop the local upstream and retry to confirm that only requests for that suffix are affected. Restart it and check that they work again. If stopping the upstream also breaks the direct test, check whether the test application has another proxy or DNS dependency configured.

Check loading, matching, and transport separately

If configuration loading fails, start with the field and nesting level reported by the core, then check commas and object and array placement. If the service starts but the application cannot connect to the local port, check the listening address, port conflicts, and whether the client is actually using this configuration. Changing outbounds usually won’t help at this point. Once the local inbound receives a request, check whether the selected outbound matches your expectations. For troubleshooting, temporarily increase log verbosity and make one new connection. Restore the usual log level afterward to avoid recording destinations for longer than necessary.

If the request matches the upstream but the connection fails, follow the chain: check that the upstream is listening, accepts the current authentication method, and can resolve and connect to the destination. The test configuration binds to the loopback address so only local applications can access it. Don’t change the listener to all interfaces just to skip a troubleshooting step. If only one outbound is causing problems, return to the previous working configuration or remove the rules that reference it. If you remove an outbound but leave its references, or move the test upstream to the first position, unmatched requests may no longer take the expected path. Before merging changes into your everyday configuration, recheck the default outbound and at least one exception.