Running a V2Ray Core on an OpenWrt Bypass Router: Transparent Proxy Setup

Learn how Xray and V2Fly cores fit into an OpenWrt main router or bypass router, covering transparent proxying, gateway routing, and DNS interception.

At a glance

For readers with an existing main router who want to test transparent proxying on a few devices with OpenWrt. First check whether traffic passes through OpenWrt, then confirm the firewall can hand connections to the core, and finally test DNS and IPv6 separately. This sequence helps avoid changing the gateway, forwarding rules, and core configuration all at once if the bypass router cuts off access.

Main Router or Bypass Router: Choose the Traffic Path First

“Transparent” proxying means apps don’t need individual proxy settings. It doesn’t mean every device on your LAN will automatically use the proxy. When OpenWrt is the main router, devices that use it as their default gateway typically send off-subnet traffic through it. When OpenWrt is just another device on the same subnet, clients keep using their existing gateway, so rules on the bypass router won’t automatically capture their connections.

Test with One Device on a Bypass Router

Recommended

Keep PPPoE and DHCP on the main router, and point the IPv4 default gateway of just one test device to the bypass router. If anything goes wrong, restore that device’s automatic network settings without affecting other devices’ DHCP leases.

Best for: an existing, stable main router and a first test on one computer

OpenWrt as the Main Router

OpenWrt handles both gateway and address assignment, centralizing traffic control. However, a firewall reload or DNS misconfiguration can affect more devices. Before migrating, confirm the WAN port, connection method, and local management access.

Best for: planning a maintenance window and managing the whole home network centrally

Pointing a Bypass Router Gateway and Running a Test

This example uses IPv4 on a single LAN: the main router is 192.168.50.1, the bypass router is 192.168.50.2, and the subnet mask is 255.255.255.0. These addresses aren’t a universal template. Use your existing subnet, and choose an address for the bypass router that won’t conflict with DHCP leases.

  1. Back Up the Current Configuration

    In LuCI, go to “System” → “Backup / Flash Firmware” and create a configuration backup. Note the current gateway, DNS, and management address. Keep another management device on the main router so you can still reach both routers if the test device loses connectivity.

  2. Set a Static Address for the Bypass Router

    On the bypass router, go to “Network” → “Interfaces” → “LAN” → “Edit” and set a static address. Set the bypass router’s own IPv4 default gateway to the main router. If the main router assigns addresses on this subnet, make sure the bypass router’s “DHCP Server” is not handing out IPv4 leases on that interface.

  3. Switch One Test Device

    Set the test device’s IPv4 default gateway to 192.168.50.2, but leave its DNS setting unchanged for now. Don’t enable transparent proxying yet. Confirm that the device can open the bypass router’s management page, then check whether ordinary forwarding provides internet access. If this fails, check the gateway, forwarding permissions, and actual return path before changing core routing.

  4. Check the Interception Path

    In LuCI, check “Status” → “System Log” for service startup messages and port conflicts, then compare firewall counters with the core’s connection logs. First verify that one destination expected to use the proxy and one expected to connect directly behave as intended. Adjust the test device’s DNS only after that.

On a same-subnet bypass router, also check the return path. Traffic that isn’t proxied and is only forwarded may return directly from the main router to the client, bypassing the OpenWrt device. If connection tracking reports problems, verify the actual path before deciding whether to change return routing, adjust the topology, or apply source NAT to specific forwarded traffic. Don’t enable NAT for the entire LAN by default: logs may then show only the bypass router’s address, making it harder to identify issues by device.

Transparent Proxy Inbounds and Firewall Interception

Xray and V2Fly are cores that can run on a router; v2rayN is a desktop client. A router’s job has two parts: the firewall selects connections for interception, then the core handles them according to its inbound, routing rules, and outbound configuration. A successful subscription import, a running process, or a listening port doesn’t prove that forwarded traffic has reached an inbound.

12345
Example transparent inbound port; must match the rules
53
Standard DNS ports for UDP and TCP
22.03
First OpenWrt release series to use firewall4 by default

Bottom line: Match the inbound to the rules first

After initiating a controlled connection, if the firewall rule counter increases but there’s no matching inbound entry in the core logs, check the protocol, port, and local delivery path before changing the outbound. If the rule counter doesn’t move at all, recheck the client gateway and the rule’s match scope.

Test DNS Interception and IPv6 Separately

The default gateway and DNS server are separate settings. After changing a test device’s gateway to the bypass router, it may still use the main router for DNS. When both the main router and the client are on the same subnet, DNS requests sent to the main router usually travel directly over the local network, bypassing the OpenWrt device. To monitor or manage these requests, first configure the test device to use the bypass router’s DNS service rather than immediately redirecting traffic across the entire network.

Choosing a Core, Troubleshooting, and Rolling Back

When choosing Xray or V2Fly, start with the protocol, transport, and security settings supported by your existing server. Then check the router’s CPU architecture, available memory, and storage. Verify configuration fields against the version of the core you’re actually using: accepting JSON fields with the same names doesn’t mean both cores interpret every option identically. Keep a working configuration when updating, and change one component at a time so you can tell whether an issue came from a core update or a network rule.

SymptomCheck firstNext step
No connection after changing the gatewayConnectivity between the device and bypass router; the bypass router’s default routePause interception and restore the basic forwarding setup
Can reach a specified IP address, but domain lookups failThe device’s resolver and its upstream serverTest LAN hostnames and public domains separately
Web pages load, but some apps time outWhether UDP and IPv6 follow the same expected pathCompare logs by protocol and address family
Transparent proxy stops working after a rebootWhether the process started and policy routes and rules were restoredFind the missing component first, then check service startup order

To roll back, first restore the test device’s gateway and DNS to their original settings. If you changed DHCP options, renew the test device’s lease and verify the settings it actually received. Next, remove the transparent interception rules and related policy routes together, following the deployment method. Stop the core last. Stopping the process while leaving rules that point to its local inbound can send matching traffic to a port with no listener.

Download v2rayNView platforms and installers