After moving transparent proxying to a Xiaomi 10G router

After Moving the Transparent Proxy Down to the Xiaomi 10G Router, I Finally Stopped Chasing Proxies on Every Device

Recently, I tinkered with my home transparent proxy architecture until it reached a pretty comfortable state: a Xiaomi 10G Router RC01 serves as the gateway, while ShellCrash + Mihomo Meta + TUN + fake-ip run on the router side, with Sub-Store, subs-check, and a lightweight management panel also placed in the router’s USB service stack.

Simply put, humans no longer have to ask the same philosophical question every day across Mac, Windows, phones, virtual machines, Docker, and browser extensions:

Are you actually going through the proxy right now or not?

Now the answer has become a more gateway-oriented one: as long as a device goes through this router, it enters the same routing and rule system. Things that should go direct go direct; things that should use a proxy use a proxy. Cloudflare Tunnel, AI services, foreign media, domestic sites, and development tools are grouped as much as possible according to their actual semantics, rather than being scattered across each device’s own proxy software.

Final Architecture

The core setup that has stabilized for now is:

LAN devices
  -> Xiaomi 10G Router RC01
  -> iptables / fwmark / policy routing
  -> TUN virtual network interface
  -> Mihomo Meta routes traffic by rule
  -> DIRECT or PROXY

Main components on the router side:

  • ShellCrash is responsible for launching Mihomo and taking over transparent proxy mode and firewall rules.
  • Mihomo Meta runs in TUN mode and serves as the actual policy engine.
  • fake-ip is responsible for pulling ordinary domain traffic into a unified, controllable path.
  • Sub-Store handles subscription processing, rule assembly, and configuration generation.
  • subs-check handles node filtering, though I later found it was also the easiest thing to squeeze the life out of a small router.
  • A lightweight router management panel is used to check status, adjust direct-connection rules, and observe the current links.

The most comfortable part of this setup isn’t the words “global proxy,” but that it turns proxying from a device-level problem into a gateway-level problem. On the device side, there’s no need to install a bunch of clients, and no need to rethink proxy environment variables every time you create a new virtual machine, switch browsers, or open a command-line tool.

Why I Finally Chose TUN, Not Redir or TProxyThis was the most interesting part of the whole tinkering process.

Redir is easy to understand: it mainly relies on NAT REDIRECT to throw TCP traffic to Mihomo. It’s simple and good enough for web pages, but its limits show easily with UDP, QUIC, IPv6, direct IP access, and similar scenarios. In today’s home networks, it feels more like an “old method that works” than the kind of complete gateway takeover I wanted.

TProxy is elegant in theory: the iptables mangle table captures TCP/UDP, preserves the original destination address, and then hands it over to a transparent socket through policy routing. On paper, it’s very well suited to transparent proxying.

But on this Xiaomi official firmware, TProxy turned into a very pretty unsolved case: the module was there, rule counters increased, the fwmark and table were correct, and route lookups also showed that packets should be delivered locally to lo, yet the application layer simply never received the transparent connections. Later, I even wrote a minimal transparent socket probe to verify it: accessing the probe directly worked fine, but TProxying LAN traffic to it produced no logs, and the client timed out.

This result was quite educational. When troubleshooting transparent proxying, you can’t just look at whether “iptables counters are increasing”; you also have to verify whether packets are actually being delivered to the application. In the end, I basically isolated the problem away from the Mihomo configuration, nodes, subscriptions, and the ShellCrash listener. It looked more like a pitfall somewhere in the official firmware’s bridging, iptables, or TPROXY delivery path.

So in the end, I settled on TUN.

TUN isn’t as “textbook transparent” as TProxy, but in actual testing on this router it was stable, covered TCP/UDP completely, and with fake-ip the client-side experience was excellent. Its cost is also very clear: domestic direct traffic also enters Mihomo first and then goes out via DIRECT, adding an extra layer of software processing, so hardware forwarding performance won’t be utilized as fully as with pure NAT.

I’m more willing to accept that cost now. Because in a home network, the most expensive thing isn’t a bit more CPU usage — it’s “not knowing why this device is behaving differently again today.”

IPv6: the easiest layer to misjudge

There was a very typical misunderstanding earlier: on the Mac, it looked like IPv6 “broke again,” but after comparing it with another Linux machine on the same subnet and with an external host, the conclusion was not “the Mac has no IPv6.”

The real situation was more convoluted:

  • The Mac has a global IPv6 address.
  • A default IPv6 route also exists.
  • External machines can even SSH to the Mac over public IPv6.
  • But local ping6, same-LAN IPv6, and TCP/HTTPS behave inconsistently.

The cause is on the router side: LAN TCP/UDP IPv6 is taken over by the transparent proxy path, while ICMPv6 is handled differently, and with leak-prevention rules on top, it ends up looking like “IPv6 is broken.”

The current handling strategy is fairly conservative:

  • Regular domains do not return AAAA records, and fake IPv4 is preferred.
  • IPv6 transparent hijacking is enabled to prevent apps from directly leaking out when they hard-code IPv6 literals.
  • If IPv6 traffic from the LAN cannot go through the TUN, it should not be allowed to leak directly out through the WAN.

This is not about trying to make “all IPv6 behavior feel as natural as a bare network.” It is about ensuring that “as long as traffic passes through this gateway, it does not bypass the policy system without you realizing it.”

Direct connection is not something one word can fully explain

There is another boundary worth noting: some management interfaces say “force direct” or “direct suffix,” but the actual semantics may simply be:

The IPs resolved from this domain are placed into the direct ipset, and after the traffic enters the router’s proxy system, it will be handled as DIRECT.

This is not the same thing as “this domain does not enter Mihomo at all.”

This difference is very obvious with Cloudflare Tunnel. For control-plane connections like Cloudflare Tunnel, if the proxy chain takes a detour and causes a 530 or connectivity issue, the natural reaction is to say, “add argotunnel.com to direct.” But what really needs to be verified is whether it ultimately shows up as DIRECT in live connections, and at which stage that DIRECT decision happens.

Later, we moved control-plane domains such as argotunnel.com and cfargotunnel.com to a more explicit position, and treated Tailscale as an optional backup management channel rather than part of the main architecture. Public IPv6 is suitable for SSH, Cloudflare Tunnel/Access is suitable for management pages, and Tailscale can be kept as insurance for a private control plane. There is no need to stack every layer to the fullest.## Rule Groups Should Follow Real-World Semantics, Not Historical Baggage

Another kind of hassle comes from rule sources.

At the beginning, I reused the common rule buckets from the Clash era, such as ProxyMedia and 国外媒体. The names sound very clear: things like YouTube, Netflix, Disney, and Spotify are what you’d call media, right?

But when I looked at the actual rules, things like AI, OpenAI, Cursor, Cloudflare challenge, Auth0, Stripe, and Sentry were also stuffed into similar “foreign media” buckets. So when you open a Cloudflare verification page, log in to ChatGPT, use Cursor, or access certain developer services, Mihomo shows that it hit ProxyMedia -> 国外媒体.

This isn’t a single domain being wrong; it’s that the abstraction is outdated.

Modern rules should at least separate these things:

  • AI / OpenAI / Claude / Gemini / Cursor / Copilot
  • Media / video / music / streaming
  • Developer services / verification / login / payments / observability infrastructure
  • General proxy
  • Domestic direct connection

So later on, I leaned more toward Mihomo-native rule sources, such as MetaCubeX, DustinWin, and blackmatrix7—systems that more clearly distinguish AI from media. Not for the sake of “chasing what’s new,” but to make sure policy group names match the real semantics of the traffic. Otherwise, whenever you’re adjusting rules, there’ll always be a little question mark in your head: why is this “foreign media” group also responsible for getting me through Cloudflare verification?

Sub-Store and subs-check: Automation Is Great, but the Source Needs to Be Clean

After moving the subscription processing pipeline onto the router, another realization hit me: the stronger the automation, the scarier source pollution becomes.

For a while, subs-check pushed the router’s load very high, even causing OOM to kill CrashCore. At first, it was easy to assume the memory parameters weren’t enough, or that concurrency was too high. Later, I discovered a more fundamental issue: some “remote subscription lists” were actually complete Mihomo configurations, but were mistakenly parsed as URL lists. As a result, fields like proxy-providers, rules, and dns all turned into strange links to be fetched, and the candidate pool exploded in size.Later, I did a few things:

  • Cleared the proxy environment variables inherited when subs-check starts.
  • Used its own system-proxy / github-proxy configuration instead of letting the entire process inherit the router’s proxy environment.
  • Reduced the concurrency of subscription fetching.
  • Disabled those full configuration sources that were not original subscription lists.
  • Kept backups, and only modified Sub-Store’s configuration object, then verified it using the generated result, instead of writing the generated YAML back as the source file.

The lesson from this was very simple: small routers can run automation, but you can’t let them consume garbage input. In an automation pipeline, having a clean source is more important than tweaking ten memory parameters later.

What’s good about this architecture now

What I’m happiest with now isn’t any single point, but that the whole system has finally formed a clear boundary:

  • Keep the device side as simple as possible: once connected to the gateway, it enters a unified policy.
  • The router side is the only main control plane.
  • SSH / file transfers prioritize public IPv6 + key-only access.
  • The web management plane can be protected with Cloudflare Tunnel / Access.
  • Tailscale is kept as a fallback and is not forced into the main data path.
  • Mihomo’s live connections and provider status are the basis for judging the truth, not guessing based on how the browser feels.
  • Rule sources shift from “this is what everyone has historically called it” to “what this traffic actually is in reality.”

Of course, it’s not perfect or without cost:

  • TUN makes even direct traffic go through an extra layer of user-space processing.
  • After a reboot, there is a recovery window of tens of seconds to a minute or two.
  • Non-TCP/UDP protocols such as ICMP, GRE, and ESP are not its target.
  • The router’s own system traffic and LAN client traffic are not the same thing.
  • Hardcoded DoH/DoT, direct IP access, and apps’ built-in VPNs can still weaken the explainability of domain-based rules.

But these boundaries are all clear now. Clear is good, because the most frustrating thing about network issues is often not “unsupported,” but “it looks supported, but it’s actually not the kind of support you thought it was.”

How I’d recommend this to others

If you also want to move the proxy down to the router, here’s what I’d suggest now:1. First, set up a rollback-safe baseline; don’t jump straight into chasing the most elegant TProxy setup.
2. If Redir meets your needs and you only need to proxy web traffic, don’t max out the system complexity.
3. If you need to cover UDP, QUIC, Docker, command-line tools, and various clients, TUN is more worth validating first.
4. IPv6 needs its own leak-prevention design. Don’t rely on accidental states like “there doesn’t seem to be a default route right now.”
5. The management plane, subscription plane, node testing plane, and real traffic plane should be considered separately.
6. Read the actual contents of rule sources; don’t trust file names.
7. Running automation on a small router is fine, but keep source size, concurrency, and memory under control.
8. Finally, always check live connections. It’s far more reliable than “I feel like this website should have gone through that group.”

The biggest takeaway from all this tinkering is probably that it turned my home network from “every device cultivating on its own” into “centralized governance at the gateway.” It’s not just a change in proxy configuration; it feels more like pushing the home network from a handmade craft into a small piece of infrastructure.

And honestly, it feels great: when I turn on a new machine, I don’t have to install a proxy client first, dig through environment variables, or wonder whether the browser and the terminal live in two different worlds. As long as it joins this network, it enters the same universe of rules.

That’s probably why, after tinkering with transparent proxying on the Xiaomi 10G router all this time, I finally feel that it was “worth it.”