RoutingA 自定义路由分流

v2rayA can use RoutingA to write routes, which is a v2ray routing markup language, which can be compiled into the json format supported by v2ray-core.

You can select “RoutingA” in “Settings - Distribution Mode of Rule Ports” to enable custom routing distribution of regular ports. If you want to set a custom route for the transparent proxy, you need to set the “Settings - Transparent Proxy” to “Consistent with the selected mode of the rule port” to enable it under the premise of the above settings.


# Customize inbound inbound, support http, socks
inbound:httpauthin=http(address:, port: 1081, user: user1, pass: user1pass, user:user2, pass:user2pass)
inbound:socksauthin=socks(address:, port: 1082, user: 123, pass: 123)
inbound:sockslocalin=socks(address:, port: 1080)
inbound:sniffing_socks=socks(address:, port: 1080, sniffing: http, sniffing: tls)
inbound:sniffing_http=http(address:, port: 1081, sniffing: 'http, tls';)

# Customize outbound outbound, support http, socks, freedom
outbound:httpout=http(address:, port: 8080, user: 'my-username', pass: 'my-password')
outbound:socksout=socks(address:, port: 10800, user: "my-username", pass: "my-password")
outbound:special=freedom(domainStrategy: AsIs, redirect: "", userLevel: 0)

# Set the default outbound, if not set, the default is proxy (this option only applies to the default inbound)
default: httpout

# Default three outbounds: proxy, block, direct

# Domain name rules
domain(domain: -> socksout
domain(full: -> proxy
domain(contains: facebook) -> proxy
domain(regexp: \.goo.*\.com$) -> proxy
domain(geosite:category-ads) -> block

# Destination IP rules
ip( -> direct
ip( -> direct
ip(geoip:private) -> direct

# source IP rule
source( -> proxy
source( -> direct

# Destination port rules
port(80) -> direct
port(10080-30000) -> direct

# source port rules
sourcePort(38563) -> direct
sourcePort(10080-30000) -> direct

# Multi-domain rules
domain(contains: google, domain:, domain: -> proxy
# Multiple IP rules
ip(geoip:cn, geoip:private) -> direct
ip(, -> direct
source(,, -> direct

# inbound inbound rules
inboundTag(httpauthin, socksauthin) -> direct
inboundTag(sockslocalin) -> special

# Also satisfy the rules
ip(geoip:cn) && port(80) && user( -> direct
ip( && network(tcp, udp) && port(1-1023, 8443) -> proxy
ip( && protocol(http) && source(, -> direct

For more concepts, please check V2Ray-Routing

  • Quotation marks can be omitted, but cannot be omitted when they contain special symbols, such as , ' " and )
  • Escape character \ is not supported yet
  • Routing rules written earlier will be matched first

Also refer to V2Ray Beginner’s Guide

Common usage

# Mainland China whitelist mode
default: proxy
# Even if there is a Chinese IP, the foreign domain name should be given priority to proxy
# Note that the LoyalsoldierSite.dat file needs to be downloaded via v2rayA in advance
# Or manually go to its repository to download, then save as LoyalsoldierSite.dat
# Warehouse address:
# domain(geosite:google-scholar)->proxy
domain(geosite:category-scholar-!cn, geosite:category-scholar-cn)->direct
ip(geoip:private, geoip:cn)->direct
# GFWList mode
default: direct
# Academic website
domain(geosite:category-scholar-!cn, geosite:category-scholar-cn)->direct
# domain(ext:"LoyalsoldierSite.dat:gfw", ext:"LoyalsoldierSite.dat:greatfire")->proxy
# Telegram
# The commented out rule below requires the IP file from Loyalsoldiser
# Warehouse address
# After downloading it can be saved as LoyalsoldierIP.dat
# ip(ext:"LoyalsoldierIP.dat:telegram")->proxy
# Use a custom DAT file (needs to put it in the correct directory)
# Ports with Authentication and Routing
inbound: socksauthin=socks(address:, port: 1080, user: 123, pass: 123)
inbound: httpauthin=http(address:, port: 1081, user: 123, pass: 123)

inboundTag(socksauthin, httpauthin)->direct
# Different inbound traffic goes to different outbound
inbound: crawlerin = http(address:,port:30001)
inbound: crawlerin2 = http(address:,port:30002)
inbound: crawlerin3 = http(address:,port:30003)
inbound: crawlerin4 = http(address:,port:30004)


Edit this page on GitHub

Last update on: Oct 12, 2022 23:54 +0800

Contributors: liangyongxiang mzz2017 I404I cubercsl