Before choosing where to run Xray, identify which device connects your home to the internet, assigns addresses to your devices, and handles proxy traffic. This guide compares two network layouts, walks through testing with a single device, and explains how to restore your original setup if connectivity fails.
Main router vs. secondary gateway
Xray is a proxy core. It does not assign addresses to devices on your home network, and starting the process does not automatically route traffic through it. Devices must either connect to a proxy port directly or send traffic through a gateway configured for transparent proxying. Before deployment, distinguish between the default gateway, DNS server, and proxy listening address. They can all be on the same device, but they are not interchangeable.
Secondary gateway
RecommendedKeep your main router in charge of internet access and DHCP. Connect an additional device to your LAN, then set it as the IPv4 default gateway only on devices you want to test. The secondary gateway still uses the main router as its upstream gateway. Updates can be managed separately, but you will need to maintain addresses, forwarding, and DNS settings on both devices.
Best for: Testing with a few devices using spare hardware
Run Xray on the main router
Clients keep the gateway assigned by the main router, so there is no need to change settings on each device. The main router handles internet access, regular forwarding, and proxy routing in one place. You have one fewer device to manage, but a mistake in the Xray core, routing rules, or firewall could affect the entire home network.
Best for: Firmware that explicitly supports the required forwarding method and provides separate local management and recovery access
Limit the impact of failures
If your home has network-dependent doorbells, work-from-home devices, or other equipment that cannot easily go offline, leave their gateway unchanged. Start with a single test device. Disable the proxy and confirm that restoring automatic address assignment returns it to the original network before expanding the setup.
Addressing and traffic flow for a same-subnet secondary gateway
The values below are examples, not firmware defaults or speed-test results. Assume the main router uses 192.168.50.0/24 and its DHCP pool is 192.168.50.100 through 192.168.50.199. If your network uses a different subnet, substitute the values for your setup and make sure the secondary gateway's address is unused.
- Accessing devices on the same subnet: Test devices usually connect directly to printers and file servers without going through the default gateway. Being able to print confirms local connectivity, but does not prove that proxy routing is working.
- Accessing external destinations: The test device sends IPv4 traffic outside its local subnet to the secondary gateway. Depending on its configuration, the gateway either forwards traffic directly or sends it to Xray. Xray establishes the proxy connection, which then passes through the main router to the upstream network.
- Handling return traffic: With a single-interface setup on the same subnet, replies to direct connections may go straight from the main router to the test device, bypassing the secondary gateway. If your routing setup requires the secondary gateway to see traffic in both directions, check the firmware documentation for source NAT or a separate-subnet option. Do not assume the routing path is correct just because a webpage occasionally loads.
Test a gateway change with one device
The steps below use the OpenWrt LuCI interface and a Windows 11 test device. Menu names may differ between firmware translations. Before you begin, follow your firmware documentation to configure forwarding and proxy access on the secondary gateway, and make sure you can still access its local management interface. Changing the default gateway alone does not create transparent proxy rules.
Back up the current configuration
In LuCI, open “System” → “Backup / Flash Firmware” and create a configuration archive. Separately note the main router's LAN address, DHCP pool, and current DNS settings. The archive may contain credentials, so store it somewhere secure on a local device.
Configure the secondary gateway
On the secondary gateway, open “Network” → “Interfaces” → “LAN” → “Edit” → “General Settings” and check its static IPv4 address, subnet mask, and upstream gateway. Under “DHCP Server” for the same interface, make sure it does not assign addresses on the shared subnet. If the secondary gateway does not manage IPv6, also check that it is not sending router advertisements to that subnet.
Change the gateway on one device
For a wired Windows 11 connection, go to “Settings” → “Network & internet” → “Ethernet” → “IP assignment” → “Edit” and select manual configuration. For example, use the confirmed-unused address
192.168.50.20, subnet mask255.255.255.0, and gateway192.168.50.2. Enter a known working DNS server explicitly to avoid changing the gateway and DNS paths at the same time.Test each part separately
Run
ipconfig /allto check the active gateway and DNS server. First open the main router's management address, then usenslookupto check name resolution. Next, start fresh connections to one destination that should use the direct route and another that should use the proxy. Check the secondary gateway logs to confirm the selected outbound route for each. If your browser uses its own encrypted DNS, check that resolution path separately.Verify rollback
Set the test device's “IP assignment” back to “Automatic (DHCP).” If you changed “DNS server assignment” separately, restore that as well. Reconnect to the network, confirm that the main router is the gateway again, then test LAN access, DNS resolution, and internet connectivity.
Hardware choices and ongoing maintenance
When choosing a device, check its firmware, CPU architecture, and writable storage before comparing throughput. The firmware must support your chosen traffic interception method and firewall rules. Having an Xray binary that runs does not mean the device can provide transparent proxying. Leave enough room for the core, rule sets, and updates so the device can save future changes as well as start up.
| Check | How to check | What to look for |
|---|---|---|
| CPU and throughput | On the same wired device and destination, test direct and proxied downloads separately while monitoring CPU load per core. | If one core stays fully loaded during proxy use and throughput stops increasing, check the processing capacity of the device running Xray first. |
| Memory and storage | Monitor available memory while loading rules and handling multiple devices. Before updating, check the free space on writable partitions. | Use system logs to diagnose process exits. A low idle memory reading alone is not enough to identify the cause, and not every exit is due to insufficient memory. |
| Updates and downtime | Record firmware, core, and rule-set versions. Change one thing at a time, then retest direct and proxied traffic and LAN access. | Restarting the main router affects the whole home. If the secondary gateway goes offline, devices using it for their gateway or DNS will also be affected. |
Common secondary gateway issues
Why is some traffic still going through the main router after changing the gateway?
First, distinguish between IPv4 and IPv6. Changing the IPv4 default gateway manually does not change the IPv6 default route learned through router advertisements. Run route print -6 on Windows to check the IPv6 default route. Then either configure IPv6 routing for your test setup or clearly limit testing to IPv4.
Why can I reach the router but not open websites by domain name?
Run ipconfig /all to see which DNS server the device is actually using. Then run nslookup example.com 192.168.50.1 to test the example main router's DNS service directly. If that works but the default query times out, fix the device's DNS settings first, then check Xray's outbound rules.
Why are downloads still slow when the proxy log shows connections?
Compare direct and proxied connections to the same destination, and record CPU load and the negotiated speed of the wired port during each test. A logged connection only confirms that traffic entered the corresponding path; it does not guarantee sufficient bandwidth on the upstream connection or device link. You can compare using the same node in a desktop client, but do not run a desktop proxy at the same time as gateway testing.
Why doesn't traffic switch back to the main router when the secondary gateway is turned off?
A manually entered gateway does not change automatically when that device shuts down. Restore automatic IP and DNS settings on the test device first. If you changed the main router's DHCP options, restore its gateway and DNS settings before having affected devices renew their leases.