Network Topology: Main Router or Single-Interface Bypass Gateway
First, identify the default gateway used by your devices, then decide where to install mihomo. In a main-router setup, OpenWrt handles the WAN connection, DHCP, and routing, so devices already send off-subnet traffic through it. In a bypass-gateway setup, the existing router continues providing internet access and IP addresses, while a second OpenWrt device joins the same LAN. Even if that device can access the internet and update subscriptions, it will not receive traffic from other devices unless their traffic is routed through it.
| Setup | Example addresses | Device default gateway | Test scope |
|---|---|---|---|
| OpenWrt main router | LAN: 192.168.1.1/24 | 192.168.1.1 | Start by limiting transparent proxy rules to one device |
| Single-interface bypass gateway | Main router: 192.168.1.1; bypass gateway: 192.168.1.2/24 | Set the test device to 192.168.1.2 only | Leave DHCP settings unchanged on all other devices |
In a single-interface setup, the bypass gateway's own default gateway remains 192.168.1.1. Reserve 192.168.1.2, or keep it outside the main router's DHCP pool, to avoid an IP conflict. Keep only one DHCP server on the same broadcast domain. After confirming the address is unused, set a static IPv4 address on the test device, such as 192.168.1.50/24. Note its original gateway and DNS settings before switching so you can restore them later.
Kernel and Config: Check the Architecture Before Launching
On OpenWrt, run uname -m to check the running kernel architecture, then use ubus call system board to identify the firmware target and device model. Common values include aarch64 for Linux ARM64 builds and x86_64 for Linux AMD64 builds. For 32-bit ARM or MIPS, check the release notes for the required instruction set and endianness as well; the device model alone is not enough. If the binary exists but will not run, check its execute permissions, architecture, and runtime environment before troubleshooting the config.
- Choose a permanent working directory. For example, use
/etc/mihomoand store the main config at/etc/mihomo/config.yaml. Rundf -hfirst to check available space, leaving room for rule sets, proxy-provider caches, and geodata./tmpis fine for a quick test, but its contents will not survive a reboot. - Check the subscription contents. Make sure it provides a config supported by mihomo, or a proxy list referenced by the main config through
proxy-providers. A subscription URL is not a YAML config, and a standalone proxy list is not a complete config with proxy groups and rules. Subscription links may contain credentials, so do not share them in public logs or screenshots. - Test before setting up a service. This example assumes the binary has been extracted to
/usr/bin/mihomoand is executable. Check the installed version and validate the config, then launch mihomo in the foreground to check for port conflicts and confirm that rule sets load. Once it is stable, use OpenWrt'sprocdto manage the service with the same directories and config arguments.
/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
Transparent Proxying: Test an Explicit Proxy Before Redirecting Traffic
Step 1: Test mihomo's outbound connection without changing the gateway
If your config uses mixed-port: 7890 and the test device can reach the bypass gateway's LAN listener, run the command below from a device with curl. This tests an explicit HTTP proxy only. Check the mihomo logs to confirm the request used the expected proxy group: a page loading successfully could simply mean it matched a DIRECT rule.
curl --max-time 10 --proxy http://192.168.1.2:7890 https://example.com/
Step 2: Choose TUN or TProxy—don't enable both
TUN receives traffic through a virtual network interface. OpenWrt needs a working /dev/net/tun; if it is missing, check for a kmod-tun package built for your firmware's kernel. After enabling TUN, confirm that the routing and forwarding settings cover LAN devices, not just traffic generated by OpenWrt itself. Compare ip rule show and ip route show table all before and after enabling it. Check that proxy outbound traffic, LAN management addresses, and the upstream gateway still follow the expected routes.
TProxy relies on firewall matches, packet marks, and policy routing. Listening on tproxy-port does not redirect traffic by itself; selected TCP or UDP traffic must also be directed to that port. The standard firewalls in OpenWrt 23.05 and 24.10 use firewall4 and nftables. Inspect active rules with nft list ruleset, and avoid copying iptables scripts written for the older firewall3 stack. Start with a single test device so existing proxy plugins and new rules do not process the same connection at once.
With a single-interface bypass gateway, inbound and outbound traffic may use the same LAN interface. For connections not captured by transparent proxy rules and still routed by the kernel, the upstream main router may send replies directly to a device on the same subnet. When troubleshooting, distinguish between a forwarded connection whose return traffic bypasses the gateway and proxy outbound traffic being captured again. For the first issue, check the topology and whether the return path must be symmetric; for the second, check route and packet-mark exclusions. Do not use network-wide NAT to mask either problem.
Gateway and DNS: Test IPv4, IPv6, and DNS Resolution Separately
The default gateway and DNS server are separate settings. In the bypass-gateway example, changing the test device's IPv4 gateway to 192.168.1.2 does not change its DNS server. If the device still sends queries to 192.168.1.1 on the same subnet, they will usually go straight to the main router—even when the bypass gateway is the default gateway.
- Set a clear DNS entry point. If the bypass gateway handles DNS, devices typically send queries to its
53port. You can have dnsmasq listen for device queries and forward those that should go to mihomo to its local listener, such as127.0.0.1:1053. Do not let both services compete for port53on the same address, or send mihomo's upstream queries back to dnsmasq in a loop. - Match Fake-IP responses to the traffic interception path. With Fake-IP enabled, devices receive virtual addresses mapped by mihomo, not the remote servers' real addresses. Connections to those addresses must return to the mihomo instance that maintains the mappings. Run
nslookup example.com 192.168.1.2to query the actual DNS entry point, then connect from the same device and check the logs. A DNS response alone does not prove that the proxy path works. - Check IPv6 separately. If you change only the IPv4 gateway, a device may still get an IPv6 default route from the main router's router advertisements. If IPv6 is not intercepted, dual-stack sites may use the original route over IPv6. Check both routing paths and test connections over each; one IPv4 test cannot confirm that the whole network is covered.
Before Going Live: Test Your Rollback Before Expanding Coverage
- Verify rule matches. Remove the explicit proxy settings from the test device, then test a LAN management page, a site expected to connect directly, and a site expected to use the proxy. Check the mihomo logs to confirm which policies matched. If your applications rely on UDP, test them separately; loading a webpage does not verify UDP traffic.
- Check what happens after a reboot. Use
logreadto review service startup messages. Confirm that the config and rule caches persist, firewall rules remain active after a reload, and subscriptions and rule sets can update once the network interfaces are ready. If only outbound connections fail after reboot, first check that WAN access, the default route, and DNS are available before changing proxy groups. - Test the rollback for real. In a bypass-gateway setup, restore the test device's original DHCP settings and confirm that both its gateway and DNS are back to normal. In a main-router setup, remove transparent interception using the same steps used to enable it, then stop mihomo so leftover rules do not send traffic to a closed port. Confirm the original connection works before expanding coverage or changing DHCP options.
Troubleshooting priorities depend on the symptoms: if the explicit proxy fails, check mihomo's outbound connection first; if it works but transparent connections produce no logs, check the device's gateway, interception scope, and firewall; if the logs show a rule match but domain access fails, check the DNS response, virtual IP mapping, and return path. For more symptom-based troubleshooting, see the troubleshooting manual.