Why your DOMAIN rules still lose to GEOIP or MATCH
Routing in Clash Meta (Mihomo) is a pipeline: first packets arrive with whatever tuple the kernel presents—often destination IP and port—then DNS may have run earlier, fake-ip may have rewritten addresses, and finally your rules: section decides which outbound wins. Domain-style rules (DOMAIN, DOMAIN-SUFFIX, DOMAIN-KEYWORD) only work when the engine already associates the flow with a hostname. If the connection was opened straight to a CDN edge address, a stale resolver answer, or an IP literal your rules never learned as a name, the evaluator reasonably falls through to broader clauses such as GEOIP or MATCH. Users perceive that as "sniff does nothing" or "wrong node" even though TUN capture is perfect.
This gap shows up constantly with games, UDP-heavy clients, and HTTPS to shared IPs: the binary resolves once (or embeds an IP), connects, and your rule stack only sees "TCP 443 to 104.x" until something reconstructs intent. Commercial CDNs multiplex thousands of unrelated sites behind the same anycast range; IP-CIDR shortcuts meant for domestic acceleration then steal flows that should ride a dedicated streaming or gaming policy group. Turning on TUN does not automatically reveal hostnames—it guarantees capture, not semantics.
The Clash Meta Sniffer bridges that semantic hole by peeking at early handshake bytes inside allowed protocols: cleartext HTTP Host, TLS SNI inside the Client Hello, and QUIC initial packets where the implementation exposes them. Those mechanisms read metadata before full decryption of application data; they are not a substitute for trusting DNS alone, but they align routing with what the remote certificate expects—often exactly what your DOMAIN rows were written to express.
If you are assembling a profile from scratch, install a maintained client build from our Clash download page, confirm baseline connectivity, then layer sniffer changes incrementally so you can roll back one knob at a time.
Sniffing for SNI is not the same thing as TLS MITM
Search threads frequently confuse sniffer with MITM because both touch TLS. They solve different problems. Sniffer modules in Mihomo observe the client-first flight to extract names such as SNI or ALPN hints without impersonating the remote server—think of it as structured parsing of bytes already on the wire inside your local stack. MITM (when a profile explicitly enables certificate interception for HTTPS inspection) terminates TLS locally, issues substitute certificates, and re-encrypts upstream; that path carries operational and trust baggage and is unrelated to the default sniffer story.
For everyday split routing you want metadata recovery, not middlebox decryption. Sniffer aims to answer: "Which hostname did this TLS session intend to reach?" so your YAML can route by domain. MITM answers a different question about inspecting payloads. Keep that distinction explicit when you read vendor presets—mixing the two concepts is how people disable security features they never needed to touch.
YAML skeleton: enable sniffer and wire sniffers
Exact keys evolve across Mihomo releases, so treat the block below as a pattern you align with the wiki for your build—never cargo-cult fields without checking syntax highlighting in your editor. At a high level you need sniffer.enable: true, port maps under sniffer.sniffing for protocols you care about, and optional tuning knobs that decide whether sniff results participate in routing decisions.
# Illustrative Mihomo sniffer block — confirm keys against your core version
sniffer:
enable: true
sniffing:
tls:
ports: [443, 8443]
http:
ports: [80, 8080-8100]
quic:
ports: [443]
force-dns-mapping: true
parse-pure-ip: true
override-destination: false
skip-domain:
- "+.push.apple.com"
tls ports cover typical HTTPS; add gaming or API ports only when logs prove traffic lands elsewhere. http remains relevant where plaintext persists on LANs or legacy redirects. quic blocks address HTTP/3 stacks—omit or narrow ports if you observe unexpected interference with UDP-heavy applications.
force-dns-mapping coordinates sniff outcomes with DNS-layer bookkeeping so fake-ip mappings line up with reconstructed names when both features run together—especially helpful when your resolver answered with a placeholder address but the handshake proves a different logical host. parse-pure-ip lets the core attempt sniff-driven classification even when the destination looked like a bare IP at admission time; disable it temporarily if you chase a regression with exotic binaries.
override-destination: when to feed sniffed names back into routing
The boolean override-destination is the lever readers argue about most. In conservative configurations it stays false: sniffers enrich logging and ancillary logic but do not rewrite the tuple used for rule evaluation. Flip it true when you intentionally want sniff-derived hostnames to steer DOMAIN matching as if DNS had spoken clearly from the start.
Use true when empirical logs show correct SNI strings yet DOMAIN clauses never fire—classic symptoms include CDN collisions and subscription endpoints sharing ranges with unrelated GEOIP buckets. Keep false while you baseline behavior, then enable briefly and watch for surprising redirects: if a client connects by IP to an IP-specific certificate edge case, overriding purely from SNI could theoretically mismatch expectations—rare, but worth knowing before you blame the core.
Paired with override semantics, maintain tight skip-domain lists for infrastructure you never want the sniffer to reinterpret—Apple push endpoints, certain banking stacks, or LAN admin UIs appear frequently in community snippets. Prefer suffix patterns (+.example.com) over thousands of literal lines.
How sniffer interacts with fake-ip and DNS mode
Fake-ip mode accelerates domain rules by handing applications synthetic addresses from a private pool; the real resolution happens inside Mihomo on a schedule aligned with policy. Sniffer complements that story when something bypasses DNS entirely—hard-coded IPs, QUIC racing ahead of resolver completion, or split-brain answers between OS stub and core. If your DNS section still misbehaves, pair this article with our Fake-IP and DNS leak guide so you do not stack two half-fixes.
Because both DNS enhanced mode and sniffer influence how hostnames materialize, adjust one axis at a time. Typical workflow: stabilize dns: with sane nameserver and fallback pairs, enable TUN plus hijack per the TUN mode guide, then introduce sniffer toggles and finally consider override-destination. Jumping straight to aggressive overrides while DNS still races upstream usually yields nondeterministic traces that resist debugging.
Rule order still matters: DOMAIN before broad shortcuts
Sniffer does not replace thoughtful ordering. If GEOIP,CN sits above fine-grained DOMAIN rows, you will continue to see domestic exits for offshore hostnames carried on confusing IPs. Move exceptions earlier in the file; reserve GEOIP and IPCIDR catch-alls for genuinely ambiguous residue. For overall discipline see rule routing best practices alongside sniffer tuning—the two topics are inseparable in production YAML.
When merging remote rule providers, remember providers append at load time according to your profile composition rules; duplicated DOMAIN entries rarely hurt, but contradictory IPCIDR ranges do. After sniffer changes, re-evaluate whether stale IP lists still deserve priority over freshly sniffable names.
Verification playbook: what healthy logs look like
Rely on Mihomo logs at info or debug level during experiments. You are looking for lines that associate a captured flow with a sniff outcome—often referencing TLS or HTTP parsers—and then show policy resolution against your intended group. If sniff never triggers, confirm ports in sniffer.sniffing align with actual destinations and that you did not silence sniffing via skip lists.
Three concrete checks:
- Trigger an HTTPS request to a hostname that shares an IP with unrelated sites; compare rule hits with sniffer disabled versus enabled. DOMAIN clauses should begin matching only once names surface.
- Exercise QUIC-capable browsers (HTTP/3) if you enabled QUIC sniffing; temporarily disable QUIC sniff if UDP sessions flap, then bisect.
- Cross-check DNS separately with
digor OS tools so you know whether anomalies originate from resolver drift rather than missing metadata.
For deeper YAML fragments and client toggles, browse our documentation hub after you capture a failing connection fingerprint—documentation makes sense once you know which knob mis-fired.
FAQ
Sniffer is on but routing still feels random—why?
Check policy groups first: flapping url-test pools and unhealthy nodes masquerade as rule bugs. Then validate rule order and confirm override-destination matches your intent. Finally inspect whether the application uses pinned certificates with embedded IPs only—some proprietary stacks resist meaningful SNI altogether.
Does sniffing hurt throughput?
Parsing the first packets is comparatively cheap versus copying bulk payload; if you measure regression, narrow QUIC ports or disable parsers you do not need. Heavy torrent or LAN replication workloads rarely benefit from TLS sniffers—consider skip lists tied to source subnets.
What about encrypted Client Hello (ECH)?
As ECH deployments spread, plaintext SNI visibility may shrink for specific sites. Sniffer effectiveness then falls back to DNS alignment and IP lists—another reason DNS tuning stays foundational rather than optional.
Closing
The Clash Meta Sniffer closes the routing gap between "we captured the packets" and "we know which service name this session belongs to." Configure TLS and HTTP sniffers thoughtfully, adopt override-destination only after logs justify it, and keep skip lists short so maintenance stays tractable. Compared with endlessly stuffing IP-CIDR databases for churn-heavy CDNs, letting SNI disambiguate flows usually produces clearer traces and fewer unexplained policy hops.
When you want a client that tracks upstream Mihomo improvements—including sniffer refinements across releases—download Clash for free from our official page and experience the difference.