This guide is for users moving their proxy entry point from a computer to OpenWrt. Using OpenWrt 24.10.x, firewall4, and a single IPv4 client as a baseline, it separates gateway forwarding, TPROXY interception, Xray routing, and DNS into four distinct roles. Addresses and ports are examples; integrate the snippets with your existing node configuration. They are not a complete, one-click deployment script.
Plan the side router's position and traffic flow
A side router is a network deployment role, not a proxy protocol. The main router handles the internet connection and DHCP, while the side router can serve as the gateway and DNS resolver for selected devices. Transparent proxy rules only work when traffic actually passes through the side router. Installing Xray on another device on the same LAN will not automatically intercept traffic from other clients.
This guide uses a single-interface side router on the same subnet: the main router is 192.168.10.1, OpenWrt is 192.168.10.2, and the test PC is 192.168.10.100. The side router's default route still points to the main router. First, manually set the test PC's IPv4 gateway and DNS to the side router; leave other devices on the existing network.
Main router and test device
- Main router address
- 192.168.10.1/24
- DHCP server
- Main router; keep a single DHCP server
- Test PC address
- 192.168.10.100/24
- Test PC gateway
- 192.168.10.2
Keep the side router's static address outside the DHCP pool, or create a static lease on the main router.
OpenWrt service endpoints
- Management address
- 192.168.10.2/24
- Default upstream gateway
- 192.168.10.1
- Transparent inbound port
- 12345, TCP and UDP
- LAN DNS
- 192.168.10.2:53
These ports serve different purposes; the DNS port is not the transparent proxy inbound port.
Single-interface forwarding also involves forwarding across the same interface, the return path, and ICMP redirects. The main router may send replies directly to the client, preventing the side router from seeing the full direct connection. Decide whether source NAT is needed by checking the return path and connection tracking; do not treat “enable NAT” as a mandatory step for every topology. During testing, also check whether the side router sends redirects that change the gateway choice for subsequent traffic.
Choose a core: verify node fields before setting up transparent proxying
v2rayN is a desktop client; Xray and V2Fly are proxy cores. OpenWrt can run a core directly as a process, with a service manager loading its JSON configuration—no desktop interface required. Subscription import, node switching, and transparent forwarding are separate capabilities. Installing the binary is only the start: you still need configuration generation, service startup, and firewall integration.
Xray core
RecommendedThis guide covers Xray with dokodemo-door and TPROXY. For nodes using VLESS, REALITY, or flow: xtls-rprx-vision, choose an Xray version that explicitly supports those fields and check the relevant documentation.
Best for: OpenWrt setups with existing Xray nodes that need a unified transparent proxy entry point.
V2Fly core
Can be used with VMess and other node types supported by the relevant version, as well as compatible transparent proxy setups. Some configuration fields are similar, but Xray protocol extensions, transport options, and configuration files cannot be assumed to transfer unchanged.
Best for: environments with existing V2Fly configurations and verified protocols and fields.
Before installation, check the CPU architecture, firmware package feeds, and available storage. OpenWrt 24.10.x uses firewall4 and nftables by default; commands written for older iptables versions cannot be mixed in as-is. TPROXY also requires the relevant kernel modules in the firmware. A successful package install or a running core does not mean packet interception is working.
ubus call system board
uname -m
xray version
nft list ruleset
ip rule show
ip route show table all
Record the actual core version, not just the package name. After an upgrade, test the configuration again—especially when nodes use REALITY, fingerprint, or specific transport fields. OpenWrt configuration paths depend on the package and init scripts; the examples below use /etc/xray/config.json.
How dokodemo-door, TPROXY, and policy routing fit together
dokodemo-door provides an inbound for receiving traffic. With followRedirect enabled, it can retrieve the original destination address through transparent proxying. It does not create nftables rules or set up policy routing for the system. Adding a port under inbounds alone will not send client traffic to it.
The Xray inbound snippet below listens on 12345 for TCP and UDP. It shows only the inbounds section; a working setup also needs valid outbounds, logging, and matching firewall rules. Listening on all IPv4 addresses supports local transparent delivery, so the firewall must restrict the source. Do not expose this port to the public internet.
{
"inbounds": [
{
"tag": "transparent-in",
"listen": "0.0.0.0",
"port": 12345,
"protocol": "dokodemo-door",
"settings": {
"network": "tcp,udp",
"followRedirect": true
},
"streamSettings": {
"sockopt": {
"tproxy": "tproxy"
}
}
}
]
}
| Layer | What it needs to do | What to check |
|---|---|---|
| nftables interception | Match the test device by source address and TPROXY selected traffic to 12345 | Rule counters increase with new requests |
| Packet marking | Apply the agreed mark to packets for local delivery | Example mark: 0x1/0x1 |
| Policy routing | Send packets with that mark to a dedicated local routing table | Example table: 100, with a local default route via lo |
| Xray inbound | Receive redirected traffic and restore its original destination | Connections appear under transparent-in |
| Xray outbound | Use routing rules to choose direct or proxy | The logged outboundTag matches expectations |
0x1 and table 100 are examples only; check for conflicts with other policy routing rules before deployment. The proxy process's own connections need a separate, identifiable bypass condition—for example, set sockopt.mark on the outbound to a value different from the interception mark, then return early in the rules. Otherwise, connections to the proxy server may be intercepted again, creating a loop.
- Before interception, exclude the side router's own addresses, management subnets, broadcasts, multicast, and other destinations that should not be proxied.
- Handle proxy server addresses and proxy process traffic separately; include domain-based node address changes in your update strategy.
- PREROUTING mainly handles forwarded traffic. Traffic originating on the router involves OUTPUT, so the same TPROXY rule cannot simply be reused.
- REDIRECT is commonly used for TCP redirection. For UDP, changing only the inbound
networkwhile keeping a firewall rule that intercepts TCP only is not enough.
This guide does not provide a universal nftables script for every firmware. Add rules through a persistence mechanism supported by firewall4, and verify the chain hook, priority, and firewall zone permissions. A temporary command succeeding does not mean the rule will survive a firewall reload.
Validate routing and DNS routing separately
The firewall decides which packets enter the core; routing decides which outbound handles them. Neither replaces the other. Xray routing rules are evaluated in order: put clear exceptions such as direct LAN access first, then handle traffic that should be proxied. Unmatched traffic usually uses the first outbound, so review the order of outbounds as well.
This routing snippet assumes the existing configuration defines a direct outbound named direct and a valid node outbound named proxy. It sends other traffic from the transparent inbound to the proxy. This broad rule is useful for testing, but it is not a complete geolocation-based routing policy.
{
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"ip": [
"10.0.0.0/8",
"172.16.0.0/12",
"192.168.0.0/16",
"127.0.0.0/8"
],
"outboundTag": "direct"
},
{
"type": "field",
"inboundTag": ["transparent-in"],
"outboundTag": "proxy"
}
]
}
}
IPIfNonMatch does not mean “resolve every domain before routing.” When the original destination is a domain and an existing rule matches, a DNS lookup for routing may not be triggered. If a transparent connection carries only a destination IP, domain rules will not get a domain automatically. Consider sniffing if needed, but it cannot identify every encrypted protocol and is no substitute for DNS planning.
Port 53 and the core's DNS are separate entry points
On OpenWrt, dnsmasq commonly provides LAN DNS on port 53. Xray's top-level dns object is mainly for lookups made by the core; it does not automatically turn Xray into a LAN DNS server. To forward dnsmasq queries to localhost on port 5353, first set up a service that actually listens on 5353 and supports the required query protocol, then configure it as the upstream.
- Client query path: The test PC should send queries to
192.168.10.2:53. dnsmasq then selects an upstream according to your plan. Avoid forwarding queries back and forth between upstreams, which can create a loop. - Node hostname resolution: Node addresses must resolve before the proxy is up. Do not make the first lookup for a node depend entirely on a proxy connection that is not yet available.
- DNS and connection egress: Keep remote DNS resolution aligned with the eventual egress where possible, so DNS does not return an address that is unreachable through the chosen route.
- App-specific DNS: Encrypted DNS in a browser does not use regular port 53. Record its settings during testing, or you may mistakenly conclude that side router DNS is not working.
- IPv6 path: Check AAAA records, the IPv6 default route, and IPv6 interception together. Configuring IPv4 alone does not mean IPv6 traffic also goes through the proxy.
Deploy in five steps: start with one client, then expand
Keep a working management path before changing the traffic entry point. The menus below follow the common LuCI layout in OpenWrt 24.10.x; themes and translations may differ slightly. Back up the configuration before changing addresses, and note the main router's address so you can restore the test PC's original gateway.
-
Back up the network
Go to “System” → “Backup / Flash Firmware” and create a configuration backup. Note the current LAN address, DHCP settings, and firewall zones. Do not replace the entire ruleset over a remote connection.
-
Set a fixed address for the side router
Go to “Network” → “Interfaces” → “LAN” → “Edit” → “General Settings” and verify the static address 192.168.10.2, subnet mask 255.255.255.0, and IPv4 gateway 192.168.10.1. Under “DHCP Server” → “General Setup,” make sure the side router is not handing out duplicate addresses.
-
Verify the core
Complete the outbound configuration using an existing working node, then run a configuration test. Confirm the service log looks normal and check that port 12345 is listening. Do not change the network-wide gateway or enable interception for all clients yet.
-
Intercept one client
Set the test PC's gateway and DNS to 192.168.10.2, and limit the interception rule to source 192.168.10.100. Test TCP first, then UDP. Check nftables counters, inbound records, and outbound tags at each layer.
-
Make it persistent and retest
Check the DNS forwarding target under “Network” → “DHCP and DNS” → “General Settings.” From the local console, reload the firewall and reboot the device; retest the rules, policy routing, and service startup. Expand the DHCP gateway settings only after all checks pass.
xray run -test -config /etc/xray/config.json
ss -lnptu
logread | grep -i xray
nft list ruleset
ip rule show
ip route show table 100
nslookup example.com 192.168.10.2
These commands are for checking status. If ss is not installed on your firmware, install the appropriate diagnostic tool or use an existing socket inspection command. A passing configuration test only means the core accepts the configuration; it does not prove the remote node is reachable. A successful DNS query only confirms that this query returned a result, not that web requests used the intended outbound.
Troubleshoot DNS works, sites won't load, and UDP failures
Troubleshoot in the order packets travel. First confirm the test PC's gateway, then check interception counters, core logs, and finally the remote connection. Avoid changing DNS, nodes, and firewall rules in the same test cycle; even if access starts working again, you will not know which change fixed it.
| Symptom | Check first | What it indicates |
|---|---|---|
| The PC has internet access, but interception counters do not change | Default gateway, rule source address, IPv6 path | Traffic may not pass through the side router or match the rule |
| Counters increase, but there are no inbound records | Mark, policy routing, local route, and zone permissions | The rule matched the packet, but it was not successfully delivered to the socket |
| Inbound records appear, but outbound connections keep retrying | Proxy server bypass and the process's outbound mark | Check for a loop involving the proxy's own traffic |
| Web pages load, but UDP apps fail | UDP interception, node UDP support, and return traffic | A successful TCP test does not verify UDP |
| Some sites time out | DNS answers, egress, MTU, and IPv6 | First distinguish DNS resolution failures, handshake failures, and large-packet transfer failures |
| Stops working after reboot | Service startup, persistent rules, and route restoration order | Temporary rules and startup dependencies were not fully saved |
For a consistent performance check, run the same HTTPS request 10 times and record the number of successes, connection time, and CPU usage during downloads. Then compare single-connection and multi-connection results. This is a suggested measurement method, not a benchmark performed for this guide. A router's rated Ethernet speed does not indicate encrypted proxy throughput; CPU, cooling, MTU, and the node connection can all be bottlenecks.
Why do rule counters and connections change when flow offloading is enabled?
Software or hardware flow offloading can change how later packets pass through the normal forwarding path, and compatibility depends on the implementation. For troubleshooting, first disable the relevant offloading options under “Network” → “Firewall” → “General Settings” and establish a repeatable baseline. Then enable them one at a time and test. A page loading occasionally is not proof of compatibility.
How to split roles between a side router and desktop clients
A side router works well for consistent home network policies; desktop clients are better for connecting independently when devices leave the LAN. The same subscription can be used on different devices, but subscription text is not a configuration file that a core can run directly. The side router still needs generated node outbounds, routing rules, and an update mechanism. Make sure importing new nodes does not overwrite the transparent inbound or anti-loop settings.
Recommended setup: manage the home gateway and mobile devices separately
OpenWrt side router
- Run Xray with a fixed transparent inbound on port 12345.
- Maintain LAN exceptions, the DNS path, and service startup.
- Turn off the desktop proxy on an intercepted PC first to verify a single-layer path.
Client devices
- Use v2rayN on desktop and select nodes independently when away from home.
- On Android, choose v2rayNG or v2flyNG based on the core you need.
- If a device-level proxy is needed, coordinate its DNS settings with the side router's bypass rules.
Start by verifying one clear proxy path per device. Before layering two proxies, define the entry point, exit, and bypass conditions for each layer.
A deployment is not complete just because “the process is still running.” The client must use the right gateway, interception rules must match, DNS routing must be clear, outbound selection must follow the rules, and the setup must still work after a reboot. Keep the original gateway and a configuration backup so devices can return to the main router during side router maintenance, without letting a node update disrupt the entire LAN.