V2Ray JSON Config Explained: Inbounds, Outbounds, and Routing

Learn how V2Ray JSON config works: logging, local inbounds, freedom and blackhole outbounds, and routing rule order—with examples.

At a glance

For users who have imported a subscription into v2rayN and are ready to explore the core config. Using a JSON example with two local inbounds and two outbounds, this guide shows where to set ports, how rules reference outbounds, and which route requests take when no rule matches. No remote servers are needed, and this example should not replace your everyday config.

Top-level structure: follow a request from inbound to outbound

App requestLocal inboundRule matchingSelected outbound

When reading a config, start with the address and port the app actually connects to—not the server address in your subscription. Once an inbound receives the request, the core matches its destination against the routing rules. The selected outbound then determines whether to connect directly, forward through a remote proxy, or terminate the request.

Minimal JSON config: two local inbounds and two outbounds

This example uses V2Ray v4-style JSON fields. SOCKS and HTTP have separate inbounds so you can test each one independently in an app. The ports are chosen for demonstration and are not v2rayN defaults. If a port is already in use, change it in both the config and the app.

10808
Example SOCKS listener port
10809
Example HTTP listener port
2
Number of example outbounds
{
  "log": { "loglevel": "warning" },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 10808,
      "protocol": "socks",
      "tag": "local-socks",
      "settings": { "auth": "noauth", "udp": false }
    },
    {
      "listen": "127.0.0.1",
      "port": 10809,
      "protocol": "http",
      "tag": "local-http",
      "settings": {}
    }
  ],
  "outbounds": [
    { "protocol": "freedom", "tag": "direct", "settings": {} },
    { "protocol": "blackhole", "tag": "block", "settings": {} }
  ],
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "domain": ["full:example.org"],
        "outboundTag": "block"
      }
    ]
  }
}

This config has one rule: if the destination domain received by the core is exactly example.org, it selects block; all other requests use the first outbound, direct. The example does not include DNS routing, remote servers, or traffic sniffing. When saving as JSON, do not add a trailing comma after the last array item or insert explanatory comments in the code.

inbounds and log: make sure the app reaches the core

listen specifies the local address where the core accepts connections. This example uses the loopback address 127.0.0.1, which is accessible only to apps on the same machine. Don’t change it to 0.0.0.0 just to troubleshoot a connection failure: that exposes the listener on all interfaces, and this example has no proxy authentication.

  1. Check the inbound protocol. For an HTTP proxy, enter 127.0.0.1:10809; for SOCKS5, enter 127.0.0.1:10808. Using HTTP for the local inbound does not limit it to HTTP websites: apps that support CONNECT can also use it to reach HTTPS destinations. UDP is disabled on the example SOCKS inbound.
  2. Make sure the test app honors the proxy settings. The system proxy provides an endpoint only to apps that follow that setting; it does not guarantee that all traffic goes through the core. For testing, use an app where you can set the proxy directly, so traffic that bypasses the proxy isn’t mistaken for a routing result.
  3. Check the core logs. warning records warnings and more serious issues for routine use. For troubleshooting, you can temporarily switch to debug, reload, retry once, then restore the original level. If binding to a port fails, resolve the listener conflict first. If no requests appear in the logs, that alone does not prove the inbound failed; also check the log level and app settings.

outbounds: the protocol defines the action; tags let rules refer to it

freedom makes the core connect directly to the destination, subject to the local network and DNS resolution. It does not let the app bypass the local proxy: the app has already sent the request to the core; the core simply doesn’t forward it through a remote proxy. blackhole terminates matching traffic. The app may show a closed connection or failed request, rather than a clear block page.

protocol
Determines how the outbound works. Remote proxy outbounds generated from a subscription may use VMess; the remote address and protocol parameters belong to that outbound, not the local listener. Don’t copy protocol-specific settings from freedom unchanged.
tag
The name used to reference an outbound in the config. direct and block are not protocol keywords. If you rename block, update the outboundTag that references it, and make sure every outbound tag is unique.
Array order
If no rule matches, the first outbound handles the request. Move blackhole to the first position in this example, and unmatched requests that would otherwise connect directly will be terminated.

routing: rules are checked in order, not ranked by specificity

The core checks routing.rules from top to bottom and uses the first rule whose conditions match. If a rule includes both inboundTag and domain, both must match. For example, add "inboundTag": ["local-http"] to the example rule, and the same domain arriving through the SOCKS inbound will no longer match it.

Destination received by the coreMatch resultExample outbound
example.orgExact domain matchblock
www.example.orgNo match; a subdomain is not an exact matchdirect
example.comNo matchdirect
Literal IP addressNo match; the example does not recover the destination domaindirect

Key takeaway: check whether the core receives a domain or an IP address

When testing a domain rule over SOCKS, choose a client option that passes the destination domain to the SOCKS5 proxy. If the app resolves the domain locally and sends only an IP address, fix the test setup before changing the rule. AsIs does not resolve domains for routing matches or reverse an IP address to find its original domain.

To match both the root domain and its subdomains, use domain:example.org. If a broader rule earlier in the list already covers the same destination—for example, sending the domain and all its subdomains direct—the later full:example.org block rule will never run. To keep this exception, place the exact-domain rule before the broader rule.

Common v2rayN config questions

Why does my edited JSON revert when I switch nodes?

First check whether you edited a standalone config or a runtime file generated by v2rayN. Generated files may be rebuilt when you switch nodes or restart the core. To keep routing changes for a regular node, use the client’s routing settings. To test a complete JSON config separately, keep a standalone copy and load it with the matching core.

Can I paste this JSON into a subscription URL?

No. A subscription URL retrieves a list of nodes; this example is a config object for the core to load. Check the current node type and core first, then decide whether to adjust routing in v2rayN or load the config separately. Don’t assume field names are interchangeable across different cores.

Neither test domain loads after the change. What should I check first?

First make sure the core loaded successfully, then test example.com with the same app and proxy inbound. It should select direct, but your machine still needs to resolve and connect to the destination. After confirming that control case, test example.org. Two pages failing to load does not, by itself, prove that blocking is working.

Download v2rayN