Skip to content
CMFA Guide

Rules, routing and overrides

This page answers "why did this site get proxied and that one did not": rules match in order and the first hit wins, while Override layers settings above the config without editing the file.

Three modes

Rule mode (default): walk the rules list in order, apply the policy on the first match, and fall back to MATCH.

Global mode: ignore rules entirely and send everything through the selected group or node. Useful for proving whether a rule is at fault.

Direct mode: the core idles and everything connects directly, while profiles and settings stay in place.

Rules match from the top

rules is an ordered list. For each connection the core takes the destination domain or IP, compares from the first entry, and the first match decides the route. Order therefore matters more than content: put DOMAIN-SUFFIX,google.com,PROXY after GEOIP,CN,DIRECT and it never fires.

The usual shape is specific domains first, geography and IP second, MATCH last:

  • DOMAIN matches exactly, DOMAIN-SUFFIX matches the suffix, and DOMAIN-KEYWORD matches anywhere — the easiest to over-match.
  • IP-CIDR and GEOIP depend on resolution, so they belong after domain rules.
  • MATCH must come last; it takes no condition.
rules excerpt
rules:
  - DOMAIN-SUFFIX,openai.com,PROXY
  - DOMAIN-KEYWORD,github,PROXY
  - GEOIP,CN,DIRECT
  - MATCH,PROXY

Where rules come from

SourceLives inHow it updates
Rules shipped with the subscriptionThe profile yamlReplaced when the subscription refreshes
rule-providersExternal rule sets, fetched on demandUpdate under Providers, or with the subscription
Client overridesLocal to CMFA, never in the yamlEdited in Override, applied instantly, never overwritten
Local fileA yaml in device storageReplace the file and reload

Scroll the table sideways

A subscription refresh overwrites rules in the yaml but never touches overrides. Your own exceptions are safer there.

What Override really changes

Override is a pass of parameter replacement CMFA performs after loading the profile and before starting the core. It does not edit your yaml; it substitutes specific fields in memory: DNS, the TUN switch, access control, log level, sniffer, GeoX URLs and more.

The benefit is settings that survive a subscription change. The cost is that it is easy to forget: if the yaml says DIRECT and traffic still proxies, check Override first.

Back up before editing rules

Editing yaml by hand means one indentation mistake stops the whole profile loading, with yaml: line N: did not find expected key. Export a copy first so you can restore it.

Rule questions

A rule is written but ignored
Check that you are not in global mode, then check order (a broader rule above it wins), then check Override for a DNS or access-control override. If all three are clear, read the Logs tab to see which rule the connection actually matched.
Are rule-providers required?
No. They split large rule sets into external files fetched on demand, keeping the main profile small. You can put everything in the yaml instead.
What are sub-rules?
A mihomo grouping mechanism that lets a provider manage rule sets separately. Clients only need to read it; you rarely edit it by hand.
Can I edit the yaml on the phone?
Yes: long-press the profile → Edit, which opens a small text editor. Save and reselect the profile for it to take effect.