Choosing a Deployment: Where mihomo Runs and How Traffic Reaches It
Choose your setup in two steps: decide where to install mihomo, then decide which connections to send through it. Running mihomo on the main router or using a side-router gateway describes where it runs; transparent proxying describes how it receives traffic. Either router can handle transparent proxying, while a side router can also offer an explicit proxy for a few apps to configure manually.
| Deployment type | How traffic reaches mihomo | Best for | Key trade-off |
|---|---|---|---|
| Run on the main router | Keep the current default gateway; have the main router handle selected traffic | A manageable main router with enough performance headroom | Firewall and forwarding changes can affect the entire network |
| Side-router gateway | Set the side router as the gateway for test devices, or selectively forward traffic from the main router | Keeping the ISP gateway in place and migrating devices one at a time | Requires careful handling of return paths, DNS, and IPv6 |
| Transparent proxy | Routing and firewall rules send matching connections to the core | Devices such as TVs and game consoles that can't be configured with a manual proxy | You must define what traffic is intercepted, which protocols are supported, and what stays on the LAN |
If you only want specific apps on your computer or phone to use a proxy, start by enabling an explicit proxy listener on the side router, for example on port 7890. Set each app to the side router's LAN address and the port it actually listens on; leave the default gateway unchanged. If LAN access is enabled, restrict it to trusted subnets or test devices. Never expose the proxy port or admin interface to the WAN.
Hardware and the Core: Check System Architecture, Then Measure Throughput
Ethernet link speed sets an upper bound, not the throughput you'll get through a proxy. Encryption, connection tracking, rule matching, and virtual-interface packet processing all use CPU. Traffic that reaches line rate with hardware offloading may not take the same fast path once it passes through a user-space proxy. Measure both proxy throughput and ordinary forwarding performance; don't rely on a single speed-test peak.
- Check the architecture and ABI: On OpenWrt, run
ubus call system boardto check the firmware target and system version, anduname -mto check the kernel architecture.x86_64usually maps to Linux amd64, whileaarch64usually maps to Linux arm64. Check the firmware's userspace architecture too. For MIPS devices in particular, confirm endianness and the exact target; don't choose a package based only on the processor brand. If using a system package provided by an integrated solution, select one that matches the firmware target and version. - Check storage and memory: On OpenWrt, use
df -h /overlayto check writable space. Leave room for the core, rule sets, and both old and new files during updates. Check memory while rule sets are loaded and devices are in use. Older devices with 16 MB of flash and 128 MB of RAM are a poor first choice for large rule sets. Whether a device has enough resources depends on usable space and actual workload, not just its advertised capacity. - Check transparent-proxy requirements: For example, on OpenWrt 24.10 with firewall4, check the nftables rules required by your integration. TUN interception requires system TUN support; TProxy interception depends on the relevant firewall and policy-routing capabilities. Don't copy an entire configuration from an older firewall setup.
Side-Router Gateway: Start with One Test Device
Same-Subnet Setup or a Separate Network
For IPv4, say the main router is 192.168.1.1/24 and the side router is 192.168.1.2/24. Reserve that address for the side router on the main router to prevent DHCP from assigning it to another device. Keep the side router's own default gateway set to 192.168.1.1. Leave DHCP on the main router unchanged at first. On just one test device, change the IPv4 gateway to 192.168.1.2 and configure DNS separately as planned.
A same-subnet setup is easy to wire, but for directly forwarded connections, the main router may send replies straight back to the client if the side router doesn't perform source NAT. In that case, the return traffic bypasses the side router. If the side router needs to track both directions of a connection, choose a topology that routes return traffic through it too. Source NAT can achieve this, but the main router will then see the side router's address as the source. For a long-term setup, put managed devices on a separate interface or VLAN downstream of the side router—for example, 192.168.20.0/24—then configure a return route on the upstream router or use NAT on the side router as needed.
Test DHCP, DNS, and IPv6 Separately
- Gateway: DHCPv4 option 3 supplies the default gateway; option 6 supplies DNS servers. They serve different purposes. Don't let two devices assign different default gateways on the same broadcast domain. Once testing succeeds, distribute settings centrally from the main router or configure managed devices individually.
- DNS: If mihomo's DNS listener is bound to
127.0.0.1:1053, clients can't use that address directly as their DNS server. A DNS forwarder on the gateway that serves the LAN should receive queries normally sent to port 53, then forward them to mihomo as configured. Make sure the two services don't forward queries to each other in a loop. - IPv6: Clients may still receive an IPv6 default route from the main router's Router Advertisements (RA). Changing only the IPv4 gateway doesn't prove that all dual-stack traffic passes through the side router. First check which IPv4 and IPv6 exits the test device is actually using. Then decide whether to route both address families through the side router or explicitly leave IPv6 traffic direct.
On OpenWrt with LuCI, go to “Network” → “Interfaces” → “LAN” → “Edit” to check the LAN address and DHCP settings. Before testing, note the client's original settings. To roll back, restore the gateway and DNS on that client only. If it originally obtained settings through DHCP, switch it back to automatic and reconnect; there's no need to reboot the main router.
Transparent Proxying: TUN, TProxy, and Rule-Based Routing
TUN passes IP packets to mihomo through a virtual Layer 3 interface. TProxy uses firewall and policy-routing rules to send traffic to a local transparent-proxy listener while preserving the original destination address. REDIRECT is commonly used for TCP; don't assume that it also handles UDP. Enabling TUN doesn't mean the whole network is intercepted either: traffic the side router can't see must first be routed or forwarded to it by the gateway, routing setup, or integration.
Transparent interception and Clash rules operate at different layers. Routing and firewall rules determine whether a packet reaches mihomo. Once it enters the core, rule mode applies policies in order, typically with the fallback MATCH rule at the end. DIRECT in the core means the core selects a direct outbound connection; it doesn't mean the system lets the connection through before interception.
- Keep access to management and LAN services: Test the router admin pages, NAS, and printers. For LAN communication—especially service discovery—don't expect a single DIRECT rule in the core to restore access. Check the system's interception scope.
- Keep the core's outbound traffic out of the interception path: Check your integration's guidance for bypassing local capture rules for connections from the core itself and for upstream DNS queries. This prevents traffic from being sent back through the proxy. If the proxy endpoint becomes unreachable after enabling interception, check this before switching nodes.
- Test subscriptions and rules separately: A successful subscription update only confirms that the update client can retrieve the content. Make a connection from a test device, check which policy the core logs show it matched, and verify that both proxied and direct outbound connections work.
With Fake-IP enabled, mihomo can return synthetic addresses that map to domain names internally. When a client connects to one of these addresses, the connection must reach the core that holds the corresponding mapping. If DNS points to the side router but traffic still exits directly through the main router, the domain may resolve but the connection won't load. Check which DNS server the client actually uses, then trace the route to the synthetic address. Also check separately for browsers or apps that use their own encrypted DNS.
Go-Live Checks: LAN, Dual-Stack, and Rollback
- Check basic access first: From a test device, open the admin pages for the main and side routers, then access a LAN service. If an admin page is unreachable, restore the client's network settings from before interception.
- Then test application traffic: Visit sites expected to go direct and through the proxy, and check the logs to confirm the matched policies. Test apps that rely on UDP separately; a webpage loading doesn't prove UDP works. On a dual-stack network, check IPv4 and IPv6 independently.
- Finally, test failure scenarios: During a maintenance window, stop mihomo and then restart the side router. Check whether clients disconnect, switch to direct access as expected, or reconnect when the service returns. Don't assume stopping the core automatically restores direct access; firewall interception rules or DNS settings that point to the side router may still be active.
If only a few devices need a proxy, start with an explicit proxy listener. If devices can't be configured individually and you want to keep the existing main router, start with the side router and one test device. Consider running mihomo on the main router when you need consistent handling for the whole network, and prepare a firewall backup, a working local admin path, and rollback steps first.