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
- 01The outbound mode decides whether rules apply at all: Global skips them and picks a group, Direct bypasses everything.
- 02In Rule mode, rules match top-down; the first hit wins and nothing below it is evaluated.
- 03The target may be a node, a proxy group, or DIRECT / REJECT.
- 04Inside a group, selection follows its type: manual, latency-tested auto, failover or load balancing.
- 05If a domain needs resolving, DNS settings apply; in fake-ip mode the core hands out a fake address and maps it back later.
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
| Type | Selection | Best for |
|---|---|---|
| select | You pick, and it stays | Regions where a stable exit matters |
| url-test | Periodic latency test, fastest wins | Your default group |
| fallback | In order; switch only when one fails | Primary plus backup lines |
| load-balance | Spread across nodes by strategy | High-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.
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
| Approach | Best for | Cost |
|---|---|---|
| Custom rules inside rules | A few fixed exceptions, like an internal domain going direct | Refreshes overwrite them; re-add after each update |
| Rule sets (remote rule-provider) | Hundreds of entries that must track upstream, like ad or streaming lists | Depends on the remote: if it fails to fetch, coverage degrades |
| Override scripts (merge or script) | The same rule must be added after every refresh | A 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.
FlClash is only a client and ships without nodes. With a plan: pay, copy the link, paste it in — three minutes to online.
Attach logs and system info when you open a GitHub issue — far more likely to get reproduced than a chat message.