Being able to run Xray on a router doesn't mean it handles traffic for your entire LAN. This guide distinguishes running the core from using an application proxy or transparent forwarding, then weighs three options: the main router, a secondary gateway, or a standalone proxy server. It's for users considering OpenWrt or a Linux mini PC. By the end, you'll know how to choose hardware, test the network, and plan a fallback—without changing the default gateway for every device right away.
Running Xray directly: the core, management interface, and traffic entry point
Xray is a core that handles proxy connections—not router firmware or a desktop app with full subscription management. On a desktop, v2rayN manages configurations and launches the core. On a router, firmware services or an administrator must handle configuration generation, process supervision, and traffic forwarding. Copying an executable to the device won't create a management web interface.
Also distinguish between a device using a proxy itself and other devices routing traffic through it. The first requires only an app configured to connect to a SOCKS or HTTP inbound. The second also involves IP forwarding, firewall rules, policy routing, and DNS. A subscription URL is not native Xray JSON configuration and can't be loaded directly by the core.
- Explicit proxy: Applications connect directly to a SOCKS or HTTP inbound. Useful for testing nodes, certificates, and remote connectivity without changing the whole LAN.
- Transparent proxying: The gateway uses firewall rules and policy routing to send selected traffic to the core. Check TCP, UDP, and IPv6 separately; a working webpage in a browser isn't enough.
- Configuration management: Converts node settings into a core configuration, then validates, starts, and reloads the service. The management component must support fields compatible with the installed core version.
Main router or secondary gateway: start with the impact of a failure
The main router typically handles the internet connection, DHCP, NAT, and default gateway. Running Xray there provides a direct traffic path, but a single faulty firewall reload could affect every device. A secondary gateway moves the proxy service to another machine, making it easier to restart or roll back independently. Simply plugging it into the same switch, however, won't route traffic through it automatically.
Test with one device through a secondary gateway
RecommendedKeep DHCP on the main router and first point a single test computer's default gateway to the secondary gateway. This is the recommended testing sequence—not a claim that a secondary gateway is faster on every network.
Best for: networks with a stable main router that need a gradual rollout and an easy rollback.
Run directly on the main router
Manage routing, DNS, and proxy rules in one place. Before upgrading, export the network and firewall configuration and keep a local management path available, so you don't have to rely on remote access to recover the device.
Best for: users comfortable restoring firmware, with enough compute and storage resources on the main router.
Standalone proxy service
A mini PC provides proxy ports on the LAN without acting as the default gateway. Configure each app individually; traffic from apps that don't use the proxy settings will still access the internet directly.
Best for: a small number of computers or apps that don't need network-wide traffic routing.
These addresses are examples, not values to copy blindly. Choose a secondary gateway address outside the DHCP pool and make sure no other device is using it. A single-port device can act as a secondary gateway, but test the return path, forwarding rules, and main router behavior together.
Main router LAN: 192.168.10.1/24
Secondary gateway LAN: 192.168.10.2/24
Secondary gateway default gateway: 192.168.10.1
Test computer: 192.168.10.50/24
Test computer default gateway: 192.168.10.2
Outbound path: test computer → secondary gateway → main router → internet
Other devices: keep 192.168.10.1 as the default gateway
On a secondary gateway in the same subnet, the main router may send replies directly back to the test computer. Whether to use source NAT depends on connection tracking and the actual topology; don't copy a global NAT rule blindly. During testing, also check whether ICMP redirects change the computer's subsequent path, which can make traffic bypass the secondary gateway after initially working.
Hardware requirements: architecture, available memory, and persistent storage
Before downloading, confirm the CPU architecture, bitness, and system ABI. “ARM” alone isn't enough to choose a package; check the specific architecture and instruction set. For MIPS devices, verify endianness and build requirements in particular. A device that can boot the firmware may still be incompatible with the Xray build's kernel or runtime requirements.
The memory and storage figures above are practical starting points for maintainability, not official minimums or throughput guarantees. Rule data, concurrent connections, logs, and firmware services all use resources. For an existing low-memory device, check available memory and peak usage. When buying new hardware, don't choose based only on whether the binary fits.
| Check | How to check | What to look for |
|---|---|---|
| System architecture | uname -m, then check the firmware device information | Confirm bitness, instruction set, and build target—not just the product model. |
| Available memory | free -m | Monitor available memory during peak usage and check whether processes are being killed for running out of memory. |
| Storage location | df -h | Make sure files are written to a persistent partition, not a temporary directory that gets cleared on reboot. |
| Kernel environment | uname -r, check firmware modules | Verify that the required capabilities for transparent proxying, such as TPROXY and policy routing, are actually available. |
Don't judge performance by the network port's rated speed alone. Proxy encryption and protocol handling mainly use CPU, so standard NAT throughput isn't a reliable measure of Xray throughput. During sustained tests, monitor CPU usage, temperature, and latency. Hardware flow offloading that normally works well can also bypass transparent proxy rules; temporarily disable the relevant acceleration and compare results when troubleshooting.
Deployment sequence: test one connection before switching a test device's gateway
The steps below use an OpenWrt network managed independently from Xray, which runs as a standalone service. LuCI menu names vary slightly by version and theme. Native Xray doesn't provide a LuCI menu, so check the configuration and start the core from a terminal. Don't install multiple components that modify the firewall just to look for a setting that isn't there.
-
Back up the network configuration
In LuCI, go to “System” → “Backup / Flash Firmware” and create a configuration backup. Note the main router's management address, LAN address, and DHCP range. Keep a computer available that can access the main router directly.
-
Set a static address
On the secondary gateway, go to “Network” → “Interfaces” → “LAN” → “Edit” → “General Settings” and set a static address, such as 192.168.10.2. If only one device will provide DHCP, go to “DHCP Server” → “General Setup” on the same page and check “Ignore interface” so both devices don't assign addresses.
-
Check the configuration
After confirming the core is executable, validate the configuration file first. Enter the remote address, port, authentication, and TLS settings provided by your service. A successful validation means the configuration can be loaded; it doesn't confirm that the remote server is reachable.
-
Test the proxy
Start with a SOCKS inbound listening on 127.0.0.1:10808 and test it on the router itself. To test directly from a computer, bind to a specific LAN address and allow access only from the test computer. Never expose the proxy port to the WAN.
-
Switch one device's gateway
Once the proxy works, configure the firmware's transparent proxy entry point, forwarding, and policy routing. In the test computer's IPv4 network settings, set the default gateway to 192.168.10.2. Set DNS separately; don't change the DHCP settings for the whole network yet.
This example assumes the executable is installed at /usr/bin/xray and the configuration is at /etc/xray/config.json. If you installed a firmware package, use its actual file paths. Some minimal firmware builds don't include curl, so check that it's available first.
/usr/bin/xray version
/usr/bin/xray run -test -config /etc/xray/config.json
curl --proxy socks5h://127.0.0.1:10808 \
--connect-timeout 10 --max-time 20 \
-I https://example.com/
socks5h sends the destination hostname to the proxy for resolution, helping separate local DNS interference from proxy connection issues. This test covers only this explicit proxy connection. It doesn't show that transparent proxying handles other apps, or that UDP and IPv6 work correctly.
Transparent proxying and DNS: four checks that are easy to miss
Changing the default gateway only sends IP packets to another machine. Firewall matching and policy routing determine whether traffic reaches Xray; DNS requests are handled according to the combined behavior of the client DNS settings, router forwarder, and core DNS rules. Test each layer separately.
- Prevent routing loops: Outbound connections from the core to remote servers must not be sent back to the proxy inbound. Depending on the forwarding setup, this may require process or routing marks, or excluding destination addresses.
- Keep LAN access working: The main router's management page, printers, and local subnets usually need direct access. Don't redirect every private address and then try to fix the results with scattered exceptions.
- Handle UDP separately: Successful TCP redirection doesn't mean UDP works. Transparent UDP forwarding usually requires the right TPROXY and policy-routing support. Check DNS on port 53 separately from other UDP applications.
- Check IPv6: Changing only the IPv4 gateway may leave clients using the main router's IPv6 default route, learned through router advertisements. Configure the corresponding IPv6 policies, or temporarily disable IPv6 in a controlled test to compare results.
If the test computer still uses 192.168.10.1 for DNS, the main router may continue resolving queries. Even after changing DNS to 192.168.10.2, confirm that the secondary gateway is listening for queries and forwarding them to the intended upstream. Browser-based encrypted DNS may bypass system DNS, so one test page can't confirm that DNS is routed correctly for the whole network.
Common issues and rollback: restore connectivity before troubleshooting rules
It fails to execute at startup. Will changing the configuration help?
Run uname -m and check the build target first. For format errors or illegal instructions, check the architecture, instruction set, and system compatibility. For permission errors, check execute permissions and whether the filesystem is mounted noexec. There's no need to keep changing node settings at this point.
The secondary gateway can connect, but the computer can't. Why?
First confirm the computer's default gateway is 192.168.10.2. Then check IP forwarding, firewall forwarding permissions, and the transparent proxy entry point on the secondary gateway. If an explicit SOCKS test works but transparent proxying doesn't, investigate the forwarding path before changing the remote node.
Why did the whole network go offline after stopping Xray?
This can happen if redirection rules still send connections to an inbound that has stopped. First restore the test computer's default gateway to 192.168.10.1 and its original DNS settings. Then use the management interface to remove the relevant rules. Test the fallback behavior when the service stops before deploying more widely.
Why is the same node faster on a computer than on a router?
Compare the same computer against the same test destination at similar times to rule out Wi-Fi differences. Then check router CPU usage, temperature, and logs, as well as MTU and duplicate forwarding. A gigabit port doesn't rule out the processor as a bottleneck.
Keep at least four records when validating the setup: whether the explicit proxy works, whether transparent TCP works, the actual DNS path, and whether direct access is restored when the service stops. Before expanding the rollout, test sleep and wake, DHCP lease renewal, and router reboot on one device to confirm the configuration persists.
If only one or two devices need a proxy, using v2rayN on desktop or choosing v2rayNG or v2flyNG on Android based on core requirements is usually easier to troubleshoot. Consider a gateway deployment when you need to manage multiple devices centrally. For more on configuration fields, see the Protocol and Core Reference. Start by identifying where traffic enters the proxy rather than configuring the entire home network at once.