Run mihomo on OpenWrt: Router and Bypass Router Setup Guide

Learn how to run mihomo on an OpenWrt main router or bypass router, with an overview of transparent proxying, DNS interception, and LAN client setup.

Main Router or Bypass Router? Start by Checking the Default Gateway

The key difference between these setups isn’t the configuration syntax—it’s which device the traffic passes through first. If OpenWrt is already the clients’ default gateway, a main-router setup usually only needs to select which devices or subnets should be handled by mihomo. If OpenWrt is connected to the main router’s LAN, it’s just another device on the same subnet by default. Installing the core won’t automatically change how other clients reach the internet.

Setup locationWhere client traffic entersTesting and rollback
OpenWrt main routerClients already use OpenWrt as their default gatewayStart with one client. To roll back, remove the interception rules and keep the existing forwarding and DHCP settings.
OpenWrt bypass router on the same subnetSet the selected client’s gateway to the bypass router, which then sends traffic out through the main routerStart by configuring one client manually. To roll back, restore its original gateway and DNS; other devices can keep using the main router.

For example, the main router might be 192.168.1.1, while the bypass router uses an available address on the same subnet, such as 192.168.1.2, that isn’t assigned to another device by DHCP. Leave DHCP on the main router and set the bypass router’s upstream gateway to 192.168.1.1. On the test computer, keep the existing IP address and subnet mask, and change only the IPv4 gateway to 192.168.1.2. If the operating system requires you to enter all network settings manually, note the current values first and use an address reserved for that computer.

Run mihomo on OpenWrt: Standalone Core or LuCI Plugin

A standalone core is a good fit if you want to manage the configuration, startup, and firewall rules yourself. A LuCI-based management plugin can make it easier to manage subscriptions, review logs, and choose which devices are intercepted, but plugins differ in the rules they generate and the firmware versions they support. Choose one approach and let it manage both the core process and interception rules. Having two services listen on the same port—or generate separate transparent proxy rules—makes troubleshooting harder.

Check These Three Things Before Installing

  • Firmware and architecture: Standard OpenWrt releases such as 23.05 and 24.10 use firewall4 with nftables by default. Instructions written for the older firewall3 and iptables setup won’t necessarily work as-is. Check the firmware version and target platform under LuCI → Status → Overview, then confirm that the plugin and its dependencies support your firmware. Don’t choose a package based on the device name alone.
  • Storage and memory: Run df -h to check available writable storage and free to check memory usage. Leave room not only for the core, but also for rule databases, subscription updates, and logs. Start with a small configuration, then check that storage and memory are still available after updates before adding more rule sets.
  • Configuration and access: Subscription URLs may contain access tokens, so don’t include them in screenshots or logs. When moving a desktop configuration to a router, check rule-set paths, listen addresses, the controller interface, and whether the current core supports the protocols you need. Keep the controller interface local if possible. If you need access from a management network, restrict the allowed sources and set an access key—never expose it to the WAN.

For the first startup, test an explicit proxy before enabling transparent proxying. Suppose the bypass router’s mixed port is set to 7890 and LAN access is allowed for the test computer. In an app that supports manual proxy settings, enter 192.168.1.2:7890. This doesn’t require changing the client’s default gateway, so you can first confirm that the core can load its configuration, select a node, and connect. Here, 7890 is just an example; use the value configured for mixed-port. Before moving on to transparent proxying, clear the app’s manual proxy settings so you can tell which route is actually in use.

Transparent Proxying: REDIRECT vs. TPROXY vs. TUN

Transparent proxying lets client apps keep their usual connection settings while the router redirects selected traffic to the core as it passes through. Once mihomo receives a connection, it applies the rules to send it direct, route it through a proxy group, or reject it. In other words, “the core is running” and “this client’s traffic is being intercepted” are two different things. Passing an explicit proxy test doesn’t prove that transparent proxy rules are working.

MethodKey settingsWhat to check
REDIRECTredir-portCheck whether LAN-side TCP traffic matches the redirect rules; this method can’t intercept UDP.
TPROXYtproxy-portCheck that firewall matching, traffic marks, and policy routing work together; supports TCP and UDP interception.
TUNtun.enableCheck whether the system can create a TUN interface and route the selected traffic through it.

Don’t enable all three methods just to troubleshoot one failure. Review the configuration generated by the management plugin, identify how it handles forwarded LAN traffic, and then check its exclusions. Depending on the setup, make sure the router’s management address, local subnets that should stay direct, and the core’s own outbound connections aren’t sent back through the core. Otherwise, you could lose access to the management page or see nodes connect but repeatedly time out.

Check IPv4 and IPv6 separately, too. A client may use a manually configured IPv4 gateway through the bypass router while still getting its IPv6 default route from the main router’s advertisements. If only IPv4 is intercepted, some connections may still use the original IPv6 route. First confirm whether both address families are meant to be covered. Then decide whether to add IPv6 interception or test each family separately on the test client; there’s no need to change IPv6 settings across the whole network right away.

DNS Interception: Who Listens on Port 53, and Who Resolves Upstream?

The default gateway forwards traffic, while the DNS address determines where clients send their queries; they don’t have to point to the same device. In a bypass-router setup on the same subnet, even if the gateway is changed to 192.168.1.2, a client with DNS still set to 192.168.1.1 will usually query the main router directly. A webpage loading in your browser doesn’t prove that DNS queries are going through mihomo.

Keep dnsmasq as the LAN DNS entry point

One straightforward setup is to have OpenWrt’s dnsmasq listen on port 53 at the LAN address and continue handling local names. It can forward recursive queries to mihomo’s local DNS listener, for example 127.0.0.1:1053, which then queries the selected upstream. Before configuring this, make sure no other process is using 1053 and check whether existing upstream settings could send queries along a different path. The upstream mihomo uses to resolve node hostnames must not loop back through the same dnsmasq forwarding entry, or you may create a DNS loop.

DNS Forwarding vs. Port Redirection

Pointing a client’s DNS setting at the router tells it to send queries there. Redirecting traditional DNS requests that pass through the router uses rules to intercept TCP or UDP traffic on port 53. Those rules can’t see same-subnet queries that bypass the bypass router, and they can’t treat DNS over HTTPS from a browser as ordinary traffic on port 53. When troubleshooting, first use a system query tool to check the response from the specified server, then check the browser’s Secure DNS settings separately.

With a fake-ip configuration, queries handled by this flow may receive an address that the core maps back to the original domain. Connections to that address must also reach the core handling the mapping. If you intercept DNS but not the corresponding connections, lookups may appear to succeed while pages fail to load. Printers, NAS devices, and router management pages should use their real LAN addresses. If local names stop resolving, check dnsmasq’s local records first, then review the scope of fake-ip-filter.

Connect LAN Devices: Test and Roll Back in Order

Before making changes, save a configuration backup under LuCI → System → Backup / Flash Firmware (menu labels may vary by firmware) and note the test client’s original gateway and DNS settings. During testing, change one thing at a time and verify each change. Start with one device; only then decide whether to provide a new gateway or DNS address to more clients through DHCP.

  1. Check routing first. Check the test client’s default gateway. In this bypass-router example, its IPv4 gateway should be 192.168.1.2. Open the router’s management page as usual, then visit a website that normally works with a direct connection to confirm that LAN access and basic forwarding are working.
  2. Then check DNS. If the example bypass router provides DNS on the LAN, run nslookup example.com 192.168.1.2 to test that server, then run nslookup example.com to check the system’s default DNS path. If the first command succeeds but the second times out, check the client’s DNS settings, DHCP options, or system resolver before changing nodes.
  3. Finally, check the rules. Turn off the test app’s manual proxy and visit a domain that your configuration is set to match a specific proxy group. In mihomo’s connection log, check the destination, matched rule, and outbound policy. If there’s no new connection, check the client’s gateway and interception scope. If a connection appears but fails outbound, check the node, upstream DNS resolution, and routing. For devices used for voice calls or gaming, test UDP separately; loading a webpage isn’t enough.
  4. Verify restart and rollback. Restart the proxy service and confirm that the listening ports and rules come back up. If the bypass router has a problem, restore the test client’s original gateway and DNS first. For a main-router setup, stop interception using the management plugin or remove the rules you just added. Once normal forwarding and DNS resolution are restored, stop the core so traffic doesn’t keep pointing to a closed port.

If only one or two devices need mihomo, a standalone client or manually configured proxy is often easier to maintain. Consider transparent interception on the main router or bypass router when devices without proxy settings, such as TVs, also need rule-based access. A setup is complete not because several options are enabled, but because test traffic and DNS follow the intended path—and you can restore the original settings if anything goes wrong.

Download Clash