Practical V2Ray Routing Strategies: A Guide to Fine-Grained Traffic Splitting by Domain and IP

5/9/2026 · 3 min

1. Overview of V2Ray Routing Strategies

V2Ray's routing functionality is one of its most powerful features, allowing users to direct data packets to different outbounds (e.g., direct connection, proxy, or specific nodes) based on traffic characteristics such as target domain, IP address, port, or protocol. With proper routing configuration, you can achieve the classic split-tunneling pattern: "direct for domestic traffic, proxy for foreign traffic." This reduces unnecessary proxy overhead while ensuring access speed and privacy.

2. Domain-Based Traffic Splitting

Domain-based splitting is the most common strategy, suitable for distinguishing traffic by website domain. V2Ray supports multiple domain matching methods:

  • Exact domain match: Use domain:example.com to match a specific domain exactly.
  • Subdomain match: Use domain:google.com to match google.com and all its subdomains.
  • Keyword match: Use keyword:google to match any domain containing "google".
  • Regex match: Use regex:.*\.googlevideo\.com to match domains matching a regular expression.

Configuration Example

"routing": {
  "rules": [
    {
      "type": "field",
      "domain": [
        "domain:google.com",
        "domain:youtube.com",
        "keyword:facebook"
      ],
      "outboundTag": "proxy"
    },
    {
      "type": "field",
      "domain": [
        "domain:baidu.com",
        "domain:qq.com"
      ],
      "outboundTag": "direct"
    }
  ]
}

3. IP-Based Traffic Splitting

IP-based splitting is useful when domain-based matching is not feasible, such as when applications communicate using fixed IPs or when you need to bypass specific IP ranges. V2Ray supports CIDR notation and individual IP matching.

Configuration Example

"routing": {
  "rules": [
    {
      "type": "field",
      "ip": [
        "geoip:cn",
        "10.0.0.0/8",
        "192.168.0.0/16"
      ],
      "outboundTag": "direct"
    },
    {
      "type": "field",
      "ip": [
        "geoip:us",
        "8.8.8.8"
      ],
      "outboundTag": "proxy"
    }
  ]
}

geoip:cn is a built-in IP database that includes all Chinese IP ranges, greatly simplifying domestic IP identification.

4. Combined Strategies and Best Practices

In production, it is recommended to combine domain and IP rules, and pay attention to rule order: V2Ray matches rules from top to bottom and stops at the first match. Therefore, place more specific rules first.

Recommended Strategy

  1. Direct for domestic domains: Use domain rules to match common domestic websites.
  2. Direct for domestic IPs: Use geoip:cn to match all domestic IPs.
  3. Proxy for foreign domains: Use domain rules to match foreign websites that need proxying.
  4. Proxy for remaining traffic: Set the default outbound to proxy, ensuring unmatched traffic goes through the proxy.

Complete Configuration Example

"routing": {
  "domainStrategy": "IPOnDemand",
  "rules": [
    {
      "type": "field",
      "domain": ["domain:baidu.com", "domain:qq.com"],
      "outboundTag": "direct"
    },
    {
      "type": "field",
      "ip": ["geoip:cn"],
      "outboundTag": "direct"
    },
    {
      "type": "field",
      "domain": ["domain:google.com", "domain:youtube.com"],
      "outboundTag": "proxy"
    },
    {
      "type": "field",
      "network": "tcp,udp",
      "outboundTag": "proxy"
    }
  ]
}

5. Common Issues and Debugging

  • Rules not working: Check rule order; ensure no earlier rule matches the target traffic.
  • DNS pollution: Consider using DNS resolution strategies like domainStrategy: "IPIfNonMatch" or "IPOnDemand".
  • Performance optimization: Avoid excessive regex rules; prefer domain and geoip for efficiency.

With fine-grained routing configuration, V2Ray becomes a powerful tool for network acceleration and secure access.

Related reading

Related articles

2026 VPN Stability Benchmark: Comparing Major Protocols Under Challenging Network Conditions
This article compares the stability of OpenVPN, WireGuard, IKEv2, Shadowsocks, and V2Ray under challenging network conditions including packet loss, high latency, and firewall interference, based on 2026 benchmark data, to guide enterprise and individual users in protocol selection.
Read more
Proxy Network Architecture Based on V2Ray: Best Practices for Routing Policies and Load Balancing
This article delves into routing policies and load balancing design when building proxy networks based on V2Ray, covering core routing rules, traffic splitting mechanisms, multi-node load balancing algorithms, and practical deployment recommendations to help readers achieve efficient and stable proxy network architecture.
Read more
V2Ray Routing Rule Optimization: Geo- and Protocol-Grained Traffic Splitting to Reduce Latency and Packet Loss
This article delves into advanced optimization of V2Ray routing rules, focusing on geo- and protocol-grained traffic splitting strategies to reduce latency and packet loss through fine-grained rule configuration.
Read more
VPN Streaming Acceleration Explained: From Protocol Optimization to Smart DNS Evolution
This article delves into the core technologies of VPN streaming acceleration, including protocol optimization, smart DNS, and routing strategies, helping users understand how to bypass geo-restrictions and enhance streaming performance.
Read more
V2Ray Deployment Guide: CDN-Based Traffic Obfuscation and Anti-Detection Strategies
This article explores how to leverage CDN technology for traffic obfuscation in V2Ray proxies to evade Deep Packet Inspection (DPI) and network censorship. It covers the principles of combining CDN with V2Ray, step-by-step deployment of WebSocket+TLS+CDN, performance optimization tips, and common troubleshooting, providing a complete anti-detection solution.
Read more
Understanding VPN Split Tunneling: Achieving Seamless Switching Between Internal and External Networks
VPN split tunneling enables users to access both private internal networks and the public internet simultaneously without routing all traffic through the VPN tunnel. This article delves into the principles, configuration methods, and best practices to help enterprises enhance network efficiency while maintaining security.
Read more

FAQ

In V2Ray routing rules, which has higher priority: domain matching or IP matching?
V2Ray matches rules in the order they appear in the configuration file and stops at the first match. Therefore, priority is determined by rule order, not the matching type. It is recommended to place more specific rules (e.g., specific domains) first, and general rules (e.g., geoip) later.
How can I debug whether V2Ray routing rules are working?
You can enable V2Ray's logging by setting `loglevel: "debug"` and observe the matching results for each traffic flow in the logs. Additionally, use the `v2ray test` command to check the configuration file syntax.
Why does traffic to domestic websites still go through the proxy even though I set domestic IPs to direct?
Possible reasons include: 1) DNS resolution returns foreign IPs; 2) Incorrect rule order where proxy rules match before direct rules; 3) Using `domainStrategy: "AsIs"` which skips IP resolution. It is recommended to use `domainStrategy: "IPIfNonMatch"` or `"IPOnDemand"`.
Read more