A closer look at V2Ray JSON config: inbounds, outbounds, and routing

Explore a minimal V2Ray config, from inbounds and outbounds to routing and DNS. Learn to read exported JSON and make safe, targeted changes.

At a glance

When reading JSON exported by a client, start with the inbound that accepts app connections, follow outboundTag to the outbound that handles each request, then check where the domain gets resolved. This guide uses a SOCKS5 setup bound to localhost to show how to test direct connections, blocking, and the default outbound—and how to apply the same approach to an existing config.

Minimal V2Ray JSON Config: Local SOCKS5, Direct Connections, and Blocking

This basic structure works with both V2Fly and Xray. It has no remote servers and does not change your system proxy: only apps explicitly connecting to the local SOCKS5 port will use it. Requests for blocked.invalid go to the block outbound; all other unmatched connections default to direct. The dns section is included to explain its role—it does not mean every connection uses the built-in DNS module.

App requestLocal inboundRule matchTarget outbound
10808
Example SOCKS5 port
18080
HTTP test port
2
Number of example outbounds
{
  "log": {
    "loglevel": "warning"
  },
  "inbounds": [
    {
      "tag": "local-socks",
      "listen": "127.0.0.1",
      "port": 10808,
      "protocol": "socks",
      "settings": {
        "auth": "noauth",
        "udp": false
      }
    }
  ],
  "outbounds": [
    {
      "tag": "direct",
      "protocol": "freedom"
    },
    {
      "tag": "block",
      "protocol": "blackhole"
    }
  ],
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "domain": ["full:blocked.invalid"],
        "outboundTag": "block"
      }
    ]
  },
  "dns": {
    "servers": ["localhost"]
  }
}

When copying, keep the array brackets and object braces, and omit the comma after the last item. First validate the syntax as standard JSON, then test the config with the kernel you actually run. Valid syntax only means the file can be parsed; it does not guarantee that field values, outbound references, or protocol settings will work. This is a kernel config, not a share link that can be imported as a node subscription.

inbounds: where the client accepts connections

inbounds is an array of inbound configurations. In this example, listen and port combine to form 127.0.0.1:10808, pointing to the same device that runs the kernel. protocol determines how apps connect. Even with the correct address and port, an app configured to use an HTTP proxy cannot complete a handshake with this SOCKS inbound.

With v2rayNG, distinguish system-wide VPN routing from a kernel's listening port. Android's VPN permission determines whether the client can route traffic through its VPN. A local SOCKS inbound in JSON does not capture every app just because it has a port. When troubleshooting a single app, first check whether it connects to SOCKS explicitly or relies on VPN mode for routing.

outbounds and routing: rule order determines where connections go

outbounds define how connections are sent or terminated. This example uses freedom for direct connections and blackhole to drop them. direct and block are just tags; the protocol determines what actually happens. If your config also has VMess or VLESS outbounds, check the server address and port, user settings, and the relevant transport and security options. The tag alone won't tell you which server it connects to.

routing.rules are checked in array order, and the first matching rule determines where a connection goes. If a rule specifies both domain and inboundTag, both conditions must match. If no rule matches, this example uses the first item in outbounds: direct. Reordering the outbounds can therefore change what happens to unmatched requests.

Config conditionMatch resultWhat to check
full:blocked.invalidMatches only blocked.invalidDoes not include sub.blocked.invalid
domain:blocked.invalidMatches the domain and its subdomainsBefore widening the match, confirm subdomains should use the same outbound
No rule matchesThis example uses the first item: directCheck outbound order, not just tag names

Check rule order before widening the match

If a new exact-match rule doesn't take effect, check whether an earlier, broader rule already matches the same request. Put exceptions before broader rules, and make sure outboundTag exactly matches the target outbound's tag. You don't need to reorder the default outbound for a single exception.

DNS and domainStrategy: who resolves the domain?

The top-level dns config controls the kernel's own DNS module. It does not change Android's Private DNS settings or intercept every query made by apps. In this example, "servers": ["localhost"] means the built-in module uses the system resolver when it selects this upstream. It does not mean you need to run a separate DNS service listening on localhost.

AsIs
Routing does not resolve domains just to match IP rules. If an app passes the domain to the inbound, routing can match it directly. If the app passes a numeric IP instead, this example has sniffing disabled, so a full: rule cannot recover the original domain from the IP.
IPIfNonMatch
If a domain doesn't match any rules as-is, routing can then try to resolve it and check IP conditions. If an earlier catch-all rule has already matched, this step may never happen.
IPOnDemand
Routing can trigger DNS resolution when it encounters an IP condition that needs checking. Compared with IPIfNonMatch, resolution may happen earlier in the matching process, depending on the rule order.

Here, domainStrategy is under routing. It controls whether a domain is resolved when choosing an outbound; it is not the resolution strategy of the outbound itself. The direct outbound in this example still needs a destination address to connect. Before changing the top-level DNS server, figure out whether the app resolves the domain first, routing resolves it to match a rule, or resolution happens only when connecting to the destination. Changing the wrong layer may leave the test results unchanged.

Validate the config: test the default outbound and blocking rule separately

Test with a separate example file on a desktop first, so you don't overwrite the config generated by the client. Start a local HTTP server in a directory used only for test files. Then open another terminal, keep the example kernel running, and send both requests. The test server listens only on the loopback address, and both requests explicitly use SOCKS, so there's no need to enable the system proxy.

python3 -m http.server 18080 --bind 127.0.0.1
curl --noproxy '' --max-time 5 --socks5-hostname 127.0.0.1:10808 http://127.0.0.1:18080/
curl --noproxy '' --max-time 5 --socks5-hostname 127.0.0.1:10808 http://blocked.invalid:18080/
  1. Test direct connections first: The first request should return the local server's page. If it fails, check that the example kernel is listening on 10808 and the test server responds on 18080. Don't assume a single failed request means DNS is the problem.
  2. Then test blocking: The second request should fail to retrieve the page. --socks5-hostname sends the destination domain to the SOCKS server instead of having curl resolve it first. Since .invalid is reserved for names that don't resolve normally, a curl error alone doesn't prove the rule matched. Temporarily set log.loglevel to debug, restart, and check whether the request was assigned to block.
  3. Finally, apply your changes: Back up the existing config, change one condition or tag at a time, then restart and retest one request expected to use the new rule and one expected to remain unaffected. When you're done, restore the original log level and stop the test server. Remove server addresses, credentials, and private domain names before sharing logs.

FAQ: Why aren't changes to an exported config taking effect?

I edited the exported JSON. Why do the old rules still apply after reconnecting?

First, make sure the client actually loads that file. In standard node mode, clients often regenerate the config from the selected node and client settings, so editing an exported copy won't change the running setup. To test a complete JSON config, use a custom-config option supported by your client or load the file directly with the relevant kernel, then check the startup logs.

Why does a domain match in my browser but not with curl?

Try again with --socks5-hostname. If the original command used --socks5, curl usually resolves the destination locally and sends the IP to SOCKS. The kernel then receives a different form of destination, which can change the result of domain-based rules.

Why can't I run a full v2rayNG config directly in v2flyNG?

v2rayNG uses the Xray kernel, while v2flyNG is based on the V2Fly kernel. Shared fields are useful to compare, but transport settings, security options, and extensions aren't always compatible. Start with a minimal config in the target kernel, then add the required outbounds and rules one section at a time. Use the first error to identify unsupported fields instead of just changing the node name shown in the client.

V2Ray Client Downloads