For readers who want to understand configs generated by v2rayN, troubleshoot routing issues, or maintain a standalone core config. This example listens only on localhost and shows how SOCKS and HTTP requests can match reject, explicit direct, or default outbound rules. It also helps distinguish invalid JSON, port conflicts, and unmatched rules.
Complete Config: Test Routing with Two Local Inbounds
This example uses the traditional config structure supported by V2Ray 5.x and commonly used with Xray. It has no remote nodes and does not rely on geolocation rule sets. The top level is an object: log, dns, and routing are objects, while inbounds and outbounds are arrays. The order of top-level keys does not determine processing order, but the order of routing.rules and the first entry in outbounds affect the result.
Save the following as config.json. The ports are chosen for this example and may differ from your current client settings. If v2rayN is already using one of these ports, stop the process occupying it or update the port in both the example config and test commands. Do not overwrite your active client config with this file.
{
"log": {
"loglevel": "warning"
},
"dns": {
"servers": ["localhost"]
},
"inbounds": [
{
"tag": "local-socks",
"listen": "127.0.0.1",
"port": 10808,
"protocol": "socks",
"settings": { "auth": "noauth", "udp": false }
},
{
"tag": "local-http",
"listen": "127.0.0.1",
"port": 10809,
"protocol": "http"
}
],
"outbounds": [
{ "tag": "direct", "protocol": "freedom" },
{ "tag": "reject", "protocol": "blackhole" }
],
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"inboundTag": ["local-socks"],
"domain": ["full:example.test"],
"outboundTag": "reject"
},
{
"type": "field",
"ip": ["127.0.0.1/32"],
"outboundTag": "direct"
}
]
}
}
log and dns: Log Levels and DNS Resolution
The key in log.loglevel is lowercase: loglevel. This example uses warning to keep warnings and errors. To troubleshoot a connection, temporarily switch to debug in a test copy, restart the core, send a single request, then check the logs around that time. Logs may contain destination addresses and local paths; remove them before sharing, and restore the original level when you're done.
dns.servers sets the upstream for the core's DNS module. Here, localhost means to use the system resolver on this machine; it does not make the core listen on a local DNS port. Whether the module is used depends on the routing or outbound resolution strategy for a request. Adding a dns section alone does not take over every DNS request from the system or browser.
- The app resolves the domain first: If an app converts a domain to an IP address before sending the request through the proxy, this inbound sees an IP. The first rule requires the target to be
example.test, so it won't match. - The app sends the domain: If a SOCKS request includes the original domain,
full:example.testcan match it directly without a DNS lookup first. That's whysocks5his used to test domain rules. - Routing needs an IP: With
IPIfNonMatch, routing can resolve the domain after the first pass finds no match, then try matching the resulting address. This example usesAsIsto make domain and IP matching easier to observe separately; it does not prevent DNS resolution later during direct connections.
inbounds: Listen Address, Port, and Inbound Tags
An inbound answers the question: “Where does the app connect?” Together, listen and port set the local listening endpoint, while protocol determines whether it accepts SOCKS or HTTP proxy requests. Set your browser's HTTP proxy to 127.0.0.1:10809; apps that need SOCKS should use 127.0.0.1:10808. These are proxy endpoints, not ordinary web addresses to open directly.
SOCKS inbound
- Tag
local-socks- Protocol
socks- Listen address
127.0.0.1:10808- Authentication
noauth- UDP
false
A dedicated rule for testing the SOCKS inbound; the test request uses TCP.
HTTP inbound
- Tag
local-http- Protocol
http- Listen address
127.0.0.1:10809
For comparison: when the same target domain comes through this inbound, it does not meet the first rule's inbound condition.
Both inbounds bind to the IPv4 loopback address and accept connections only from this machine. Do not change listen to 0.0.0.0 to fix a port conflict; that exposes the listener to a wider network and may not resolve the conflict. A tag is an identifier used by rules, not an address. If you rename the inbound tag from local-socks, update the corresponding inboundTag too. Otherwise, requests can still reach the core but won't match that rule.
outbounds: Protocols and the Default Route
An outbound answers the question: “How does the core handle the request?” The protocol determines its behavior, and the tag gives rules a name to select. In this example, direct and reject are custom tags: naming a tag direct does not enable direct connections; freedom is what actually connects directly.
| Outbound tag | Protocol | When it applies | Result |
|---|---|---|---|
direct | freedom | Matches the second rule, or no rule in this example | Connects to the target from the host running the core |
reject | blackhole | Matches the first rule | Stops forwarding; the request is not sent to the target |
Before reordering outbounds, check what happens when no rule matches
This example has no explicit fallback rule, so unmatched requests use the first entry in outbounds. To reorder outbounds while keeping direct connections as the fallback, add a rule at the end that covers both inboundTag values in this example and points to direct. Do not put this broader rule before the reject rule.
When reading a real node config, start with the outbound protocol, then check that protocol's settings, followed by the applicable transport and security settings. VMess and VLESS are not interchangeable by changing only protocol; node fields must match the protocol, server parameters, and running core. For example, Xray-specific transport or security fields won't necessarily work in V2Ray just because the top-level structure looks the same.
routing: Match Rules in Order and Select an Outbound
Rules in routing.rules are checked from top to bottom. If a field rule specifies both inboundTag and domain, the inbound and target domain must both match. The first matching rule selects the outbound; later rules are not combined. If the selected outbound cannot connect, the core does not try the next rule.
| Inbound | Target | Result |
|---|---|---|
local-socks | example.test | Both conditions in the first rule match, so the request uses reject |
local-http | example.test | The inbound does not match the first rule; with AsIs, the second IP rule doesn't match either, so the request uses the first outbound, direct |
| Either example inbound | 127.0.0.1:18080 | Matches the second IP rule and explicitly uses direct |
full:example.test matches only this exact domain, not sub.example.test. To include subdomains, use domain:example.test. 127.0.0.1/32 matches a single IPv4 address and does not restrict the destination port. The second row predicts route selection; it does not mean the reserved test domain will resolve. A rejected connection and a DNS failure after choosing direct are failures at different stages.
Config Validation and Local Testing
- First, check that the config loads. Run the check command below for the core you plan to use. For a parse error, check double quotes, trailing commas, brackets, and spelling. For an unsupported protocol or setting, confirm which core is running. A successful check does not guarantee that the ports can be bound or that a remote node is available.
- Next, start the core and test server. Start the example with
run -c config.jsonusing the corresponding core. In a second terminal, runpython3 -m http.server 18080 --bind 127.0.0.1from an empty directory set aside for testing. In a third terminal, run the request commands below. If another local service is already running, you can use it instead and update the target port accordingly. - Compare a successful request with an expected failure. The first two requests access the same local HTTP server and should both receive a response. The third sends
example.testunchanged through the SOCKS inbound and should be rejected.--noproxy ""clears the proxy bypass list for this request, preventing environment variables from excluding loopback addresses from the test. In Windows PowerShell, you can explicitly runcurl.exe.
v2ray test -c config.json
xray run -test -c config.json
curl --noproxy "" --max-time 5 -x socks5h://127.0.0.1:10808 http://127.0.0.1:18080/
curl --noproxy "" --max-time 5 -x http://127.0.0.1:10809 http://127.0.0.1:18080/
curl --noproxy "" --max-time 5 -x socks5h://127.0.0.1:10808 http://example.test/
When troubleshooting v2rayN, first check the local ports under “Settings” → “Parameter Settings,” then confirm which core the current node uses. The ports in this article are for a standalone test config and may not match the values shown in the client. The client may regenerate its runtime config when you switch nodes or restart. For repeatable comparisons, keep a separate test file and change one field at a time.