OpenWrt routers and side routers running mihomo: deployment options and network topologies

Compare running mihomo on your main router, using a side router as a gateway, and setting up transparent proxying. Learn how binaries, config directories, and LAN devices fit into each setup.

Where to Run mihomo and How to Route Traffic

First decide which device will run mihomo, then choose which connections should go through it. Running mihomo on the main router or a side router answers “where does the core run?” Transparent proxying answers “how does traffic reach the core when apps aren’t configured to use a proxy?” Both router setups can provide an explicit proxy, and either can handle transparent proxying when routing and firewall requirements are met.

SetupHow traffic reaches the coreWhat changes
Run on the main routerApps connect to a proxy port on the main router, or the router intercepts selected forwarded traffic.An explicit proxy affects only apps configured to use it. Changing forwarding on the main router can affect the entire LAN.
Side router as gatewayApps can connect directly to a proxy port on the side router. If you point client devices’ default gateway to it, you’ll also need to configure traffic interception separately.Start by changing just one client, while leaving the main router’s DHCP and existing internet path intact.
Transparent proxyOn the device carrying the traffic, use TUN and policy routing, or firewall-based forwarding, to send connections to the core.Traffic handling depends on the interception rules. Verify TCP, UDP, DNS, IPv4, and IPv6 separately.

For a first deployment, test the explicit proxy before changing the gateway or transparent interception rules. This adds just one connection path—from the test app to the core. Once that works, you can focus on forwarding, DNS, and policy routing instead of repeatedly changing subscriptions.

Core Binary and Configuration Directory

Choose a binary that matches the device’s actual Linux architecture, not just its router model or the chip listed in its specs. SSH into OpenWrt and run uname -m to check the architecture reported by the kernel, then run ubus call system board to confirm the firmware release and target. Common values include aarch64 for arm64 and x86_64 for amd64. For 32-bit ARM and MIPS, also check the ABI or endianness listed for the release build. Run mihomo -v to note the version and confirm the binary runs on the device.

Config Files, Data Directory, and Service Options

For a manual setup, you can place the binary at /usr/bin/mihomo, set the data directory to /etc/mihomo, and save the config as /etc/mihomo/config.yaml. These are example paths, not defaults shared by every OpenWrt plugin. If you manage mihomo through a LuCI plugin, first check its actual startup arguments and generated config. Direct edits to generated files may be overwritten when you save settings or update a subscription.

uname -m
ubus call system board
df -h /overlay
/usr/bin/mihomo -v
/usr/bin/mihomo -t -d /etc/mihomo -f /etc/mihomo/config.yaml

Use -d to set the core’s data directory, -f to specify the config to load, and -t to validate the config without starting the persistent proxy service. After validation, start the service with the same -d and -f options, then let OpenWrt’s service manager or your plugin manage it. A downloaded subscription may not be a complete config: a file containing only proxy nodes can’t replace a full config with listening ports, proxy groups, and rules.

What config validation does—and doesn’t—check: A valid config doesn’t guarantee that ports can bind, nodes can connect, or LAN forwarding works. Leave enough space for rule sets, proxy provider caches, and config updates. Check the free space on /overlay; available memory is not persistent storage.

LAN Access from the Main Router and Side Router

For testing, keep the existing DHCP server and default gateway, and change just one app on one client. This example uses 192.168.1.0/24: the main router is 192.168.1.1, the side router is 192.168.1.2, and the test device is 192.168.1.50. Assign the side router a static address or DHCP reservation to avoid conflicts. Its IPv4 upstream gateway should still point to the main router.

Explicit Proxy: Keep the Client’s Gateway

If mihomo runs on the side router, set the test app’s HTTP proxy to 192.168.1.2:7890. If it runs on the main router, use 192.168.1.1:7890. Here, 7890 is an example mixed-port, not a fixed default. The device must allow LAN access—for example, by enabling allow-lan and confirming the listen address covers the LAN interface. In the firewall, allow this port only from the intended LAN sources; never expose the proxy or management interface to the WAN.

To verify the setup, choose a destination that the config is known to route through a proxy policy. Check the source, matched rule, and outbound policy in mihomo’s connection list or logs. A website loading without a corresponding mihomo connection entry doesn’t prove the proxy is working. This test applies only to apps configured to use that proxy.

Side Router as Gateway: Change Only the Test Device First

To test the side router as a gateway, change the test device’s IPv4 default gateway from 192.168.1.1 to 192.168.1.2, and remove any explicit proxy settings in the app. Record the original gateway and DNS settings so you can restore them. Changing the gateway changes the next hop; it doesn’t automatically send regular web traffic to mixed-port. With ordinary forwarding alone, the client may still get online while the core receives none of its connections.

With a side router on the same subnet, outbound and return traffic don’t always pass through the same device. Traffic to the internet may go to the side router first and then leave through the main router, while replies for direct connections may go straight from the main router to the client. If your setup depends on bidirectional state tracking, verify the return path against the actual routing design—don’t assume the topology is working just because internet access is available. Check IPv6 separately: clients may get an IPv6 default route from the main router’s advertisements, and changing the IPv4 gateway won’t change that route.

Transparent Proxying: TUN, DNS, and Traffic Scope

Configure transparent proxying on the device that actually carries the test traffic. TUN is a virtual network interface; bringing it up only confirms that the device has created an entry point for IP packets. Whether forwarded LAN traffic reaches TUN also depends on routes, policy rules, the firewall, and the interception scope of your deployment tool. With firewall-based interception, redir-port handles TCP redirection. To intercept UDP with tproxy-port, you also need the corresponding transparent proxy rules and policy routing—not just a listening port.

  1. Keep a management path open. From the LAN, verify that LuCI and SSH are still accessible. Exclude the router’s management address and essential LAN services from interception, and make sure the core’s outbound connections aren’t sent back through the transparent proxy rules.
  2. Then decide which service answers DNS queries. Check the DNS address clients receive and whether OpenWrt’s dnsmasq forwards queries to mihomo. Don’t let two processes compete for port 53 on the same address. If dnsmasq keeps port 53 on the LAN, configure it to forward queries to a separate local listening port, such as 127.0.0.1:1053. That address is not the DNS server address to give LAN clients. Check the forwarding chain to make sure the two resolvers don’t send queries back and forth.
  3. Finally, verify that Fake-IP connections return to mihomo. When Fake-IP is enabled, mihomo must receive subsequent connections to the synthetic addresses it has mapped. If a client gets one of these addresses but sends its connection out through ordinary routing, you may see “DNS resolution works, but the website connection times out.” Also check whether the browser’s encrypted DNS is bypassing the resolver path configured for this test.

Test IPv4, IPv6, TCP, and any UDP-dependent apps separately. One successful page load proves only that one connection worked. A browser may switch to TCP after UDP fails, or use one address family after the other fails. Use the connection log’s source address, protocol, matched rule, and outbound result to confirm what happened.

Verify on One Client, Then Roll Back Safely

Get one test device through verification before changing DHCP or widening transparent interception. Change one setting at a time, and keep the original gateway, DNS, and firewall settings. Test again after rebooting the router to confirm the setup relies on persistent configuration—not a manually started process or temporary rules.

  • Can’t connect to the proxy port: First check that the core is running and 7890 is listening on an address reachable from the LAN. Then check whether OpenWrt allows the test device to access the port. There’s no need to change DNS yet.
  • The explicit proxy works, but the core logs no connections after changing the gateway: Check the test device’s current default route and the side router’s interception scope. Also rule out two common causes: the browser is still using its old proxy, or IPv6 traffic is still routed through the main router.
  • The rule matches, but the connection fails: Determine whether the failure is in DNS resolution by the core, the proxy group’s outbound selection, or the outbound connection timing out. Troubleshoot the node only after confirming that the connection reached the core and selected the expected outbound.

To roll back, remove the transparent interception rules first, then stop the corresponding service so traffic isn’t still being sent to a disabled listener. Restore the test device’s original gateway and DNS settings, and remove any temporary proxy settings from its apps. If you changed DHCP options, have affected devices renew their leases. For just a few apps, keep using an explicit proxy. Expand transparent proxying by source only when you need to support devices that can’t be configured to use a proxy on their own.

Download Clash