Bypass Router Topology: Start by Routing One Device Through OpenWrt

A bypass router adds an alternative path to the internet without taking over the main router’s WAN connection, Wi-Fi, or DHCP. For a same-subnet setup, the main router might be 192.168.1.1/24 and the OpenWrt bypass router 192.168.1.2/24. Keep the bypass router’s default gateway pointed at 192.168.1.1. Make sure its IP is outside the main router’s DHCP pool, or reserve the address on the main router.

  1. Keep DHCP enabled on the main router. If DHCP is enabled on the bypass router’s LAN, disable its DHCPv4 server in LuCI under “Network” → “Interfaces” → “LAN” → “Edit” → “DHCP Server” to prevent devices from receiving conflicting gateway settings.
  2. Choose one device and note its current IP address, gateway, and DNS settings. Once the bypass router can forward traffic, set that device’s IPv4 default gateway to 192.168.1.2. To test DNS on the bypass router, change the DNS server separately to the same address. Changing DNS alone does not change the next hop for application traffic.
  3. Don’t advertise the new gateway to the whole network before testing. If the test fails, restore automatic IP and DNS settings on the device, then reconnect it. Other devices can continue using the main router.

Kernel Architecture, Config Paths, and Foreground Startup

Check the OpenWrt version and executable architecture first

ubus call system board
uname -m
df -h /overlay
free -m

If uname -m returns x86_64, a Linux amd64 build is usually appropriate; for aarch64, choose Linux arm64 and verify the firmware’s userspace architecture. On older MIPS devices, check word size, endianness, and floating-point ABI rather than choosing a package by model alone. If startup reports Exec format error, check the binary format and architecture before changing YAML. Leave enough storage for rule sets, databases, and subscription updates. Files uploaded to /tmp are temporary and won’t survive a reboot.

Use a fixed working directory; validate before starting

For manual setup, place the extracted kernel at /usr/bin/mihomo and the main config at /etc/mihomo/config.yaml. The commands below assume both files are in place. Specify the working directory and main config when starting mihomo so relative rule-provider paths resolve consistently over SSH and in startup services.

chmod 0755 /usr/bin/mihomo
chmod 0600 /etc/mihomo/config.yaml
/usr/bin/mihomo -v
/usr/bin/mihomo -t -d /etc/mihomo -f /etc/mihomo/config.yaml
/usr/bin/mihomo -d /etc/mihomo -f /etc/mihomo/config.yaml

Use -v to check the running version, then verify supported config options against that release. Subscription URLs may contain credentials, so don’t post configs or logs on public forums. A subscription download may not be a complete config: if it contains only proxy nodes, import them using proxy-providers and define proxy groups and rules in the main config. Don’t replace the entire config.yaml with a node list.

After validation succeeds, check the foreground logs for listening ports and rule-set loading, then manage the process with OpenWrt’s procd or an installed management plugin. If a plugin generates firewall rules and runtime configs, change upstream settings in the plugin. Don’t start a second kernel that competes for the same ports, or use a plugin-generated temporary config as your maintenance entry point.

Transparent Proxying: Explicit Proxy, Redirect, TProxy, and TUN

First test mihomo on the device where it runs by using an explicit proxy. For example, if the config sets mixed-port: 7890 and the test tool runs on that device, use 127.0.0.1:7890. Once it connects, test LAN forwarding. This port accepts HTTP or SOCKS proxy requests, but changing a device’s default gateway sends ordinary IP traffic—not traffic that automatically enters mixed-port.

Entry pointHow traffic reaches itWhat to check
mixed-portApps explicitly configured with an HTTP or SOCKS proxy addressVerify the node and rules first; for LAN access, check the listening address and firewall
redir-portThe firewall redirects matching TCP connections to a local portTests TCP only; it does not confirm that UDP apps will work
tproxy-portTransparent sockets use firewall marks and policy routing to receive TCP or UDPThe listener, rule match, mark, and local route must all be in place
tunRouting sends selected traffic to a virtual network interfaceCheck the TUN driver, which forwarded traffic is selected, and the kernel’s outbound path

OpenWrt 22.03 and later use firewall4 and nftables by default. Before deployment, confirm which firewall backend is actually in use; don’t copy older iptables examples into an fw4 setup unchanged. When using TProxy, limit interception to the test device at first. Exclude router management addresses and LAN destinations that should connect directly. Also make sure mihomo’s own upstream connections aren’t sent back into the kernel by the same rules. With TUN, creating the virtual interface isn’t enough: make a request from a LAN device to confirm its forwarded traffic is selected, rather than only requests originating on the bypass router entering TUN.

A same-subnet bypass router can also cause asymmetric return paths: after forwarding traffic that wasn’t intercepted, the main router may send the response directly to the device. If a problem only affects traffic that needs to pass through the bypass router in both directions, check forwarding and the return path. Then decide whether to use a separate downstream subnet or apply source NAT to traffic that needs a symmetric return path. With source NAT, upstream devices see the bypass router’s address instead of each client’s, so it’s not a universal fix.

DNS Interception: Keep dnsmasq on Port 53 and Use a Separate mihomo Port

A straightforward path for troubleshooting is to have a device query 192.168.1.2:53, with dnsmasq on the bypass router handling local names and forwarding other requests to 127.0.0.1:1053. Configure mihomo with dns.enable: true and dns.listen: 127.0.0.1:1053. In the bypass router’s LuCI, check the DNS forwarders under “Network” → “DHCP/DNS”. The dnsmasq forwarding address uses 127.0.0.1#1053—a hash, not a colon.

  • Upstream path: If dnsmasq should use mihomo exclusively, check whether it also reads other upstreams from a resolv file. mihomo must be able to resolve its own upstream and proxy-node hostnames; otherwise, bootstrap lookups may loop back to dnsmasq and then to the same listening port.
  • Returned addresses: With fake-ip, a device may receive a synthetic address in the 198.18.0.0/16 range, depending on the config. Connections to that address must pass through the mihomo instance holding the mapping. If you intercept DNS but leave application traffic on the main router, names may resolve while websites remain unreachable.
  • Interception scope: If you also redirect traditional DNS queries from devices, account for both UDP and TCP on port 53, and exclude upstream requests originating on the bypass router. Browser DoH and system DoT don’t use traditional port 53 queries. First check whether encrypted DNS is enabled on the test device before deciding whether standard DNS interception is working.
nslookup example.com 192.168.1.2

Run this command on the test device to check whether the bypass router’s DNS endpoint responds. It specifies the server explicitly, so it doesn’t prove the browser is using that endpoint. Then compare the device’s actual DNS settings with mihomo’s connection logs to confirm the paths taken by DNS queries and application traffic.

Deployment Checks: Troubleshoot by Where the Failure Occurs

  1. Explicit proxy also fails: Go back to config validation and startup logs. Check the listening port, proxy-node DNS resolution, and connection to the node. Don’t change fw4 or DHCP yet.
  2. Explicit proxy works, but transparent traffic doesn’t appear in the logs: Check that the browser has no leftover manual proxy settings, then verify the device’s default gateway, IPv6 routes, and firewall counters. For TProxy, also check whether ip rule show and ip route show table all include the expected mark rule and local-delivery route.
  3. Connections appear in the logs, but the wrong policy is applied: Check the actual destinations and matched rules in the logs. mihomo evaluates rules in order, so a broad rule near the top can match connections prematurely. Put the fallback MATCH rule last. Test one destination that should connect directly and another that should use a proxy group; don’t rely on a single page load to validate the rules.
  4. Web pages load, but UDP apps don’t work: Check separately whether the entry point supports UDP, whether the current proxy-group node can forward UDP, and whether IPv4 and IPv6 follow the same path. A successful TCP page load doesn’t verify any of these.
  5. It only fails after a reboot: Check the startup service, working directory, and interface initialization order, then retest after reloading the firewall. Make sure the proxy entry point and controller API aren’t exposed to the WAN before expanding DHCP distribution.

Before rolling this out, test a rollback on at least one device: restore its original gateway and DNS settings, then confirm it can use the main router. If you changed DHCP options on the main router, restore them and renew the device’s lease. Then disable interception rules and services on the bypass router so devices don’t keep sending requests to an endpoint that’s no longer running.