Configuration · 9 min read

Rules and proxy groups

How a request is matched, which rule it hits and which node it lands on, plus rule versus global mode and why a rule change needs a reconnect.

All routing comes from the mihomo core. Understanding the path a request takes beats memorising syntax: most misconfigurations are ordering or group-target mistakes.

The path of one request

  1. 01The outbound mode decides whether rules apply at all: Global skips them and picks a group, Direct bypasses everything.
  2. 02In Rule mode, rules match top-down; the first hit wins and nothing below it is evaluated.
  3. 03The target may be a node, a proxy group, or DIRECT / REJECT.
  4. 04Inside a group, selection follows its type: manual, latency-tested auto, failover or load balancing.
  5. 05If a domain needs resolving, DNS settings apply; in fake-ip mode the core hands out a fake address and maps it back later.
A minimal rule set (order is priority)
rules:
  - DOMAIN-SUFFIX,github.com,PROXY        # 域名后缀
  - DOMAIN,api.example.com,PROXY          # 精确域名
  - DOMAIN-KEYWORD,google,PROXY           # 关键词
  - IP-CIDR,10.0.0.0/8,DIRECT,no-resolve  # 内网直连,不做 DNS 解析
  - GEOIP,CN,DIRECT                       # 国内 IP 直连
  - MATCH,PROXY                           # 兜底:其余全部走代理

Four group types

TypeSelectionBest for
selectYou pick, and it staysRegions where a stable exit matters
url-testPeriodic latency test, fastest winsYour default group
fallbackIn order; switch only when one failsPrimary plus backup lines
load-balanceSpread across nodes by strategyHigh-volume downloads

Rule, Global, Direct

The three buttons on the dashboard switch outbound mode, not the proxy itself. A common misconception: Direct does not shut the proxy down — the core keeps running, traffic simply stops using nodes.

Debugging order

First check which rule a connection matched on the Connections page, then look for resolution failures in Logs, and only then suspect the node. If Global works, the rules are almost certainly at fault.

Custom rules, rule sets and override scripts

ApproachBest forCost
Custom rules inside rulesA few fixed exceptions, like an internal domain going directRefreshes overwrite them; re-add after each update
Rule sets (remote rule-provider)Hundreds of entries that must track upstream, like ad or streaming listsDepends on the remote: if it fails to fetch, coverage degrades
Override scripts (merge or script)The same rule must be added after every refreshA broken script invalidates the whole profile and is harder to debug

Prefer the simplest option that works: start with a custom rule, move it into an override script once you know it is permanent, and only introduce a rule set when the list is too long to write. Rule sets look easiest but hand the question of completeness to a remote host.

Three common traps

  • An IP-CIDR rule without no-resolve triggers a DNS lookup first and makes things slower.
  • Putting GEOIP,CN,DIRECT first will misroute foreign sites that use domestic CDNs.
  • MATCH must be last; a MATCH in the middle makes every later rule dead code.
No subscription yet?

FlClash is only a client and ships without nodes. With a plan: pay, copy the link, paste it in — three minutes to online.

Buy a plan
Still stuck?

Attach logs and system info when you open a GitHub issue — far more likely to get reproduced than a chat message.

Open an issue