If you want "every ad domain" or "every site in some category" routed the same way, hand-writing dozens of DOMAIN-SUFFIX lines isn't realistic — and the community has already built and maintains rule sets for exactly this. Rule Provider is the mechanism that lets your config "reference" one of these remote rule sets: you write one line locally, and the actual rule content stays up to date automatically from the remote file.
01The Basic Syntax
Rule Provider works in two steps: declare where the rule set comes from under rule-providers, then reference it in rules with RULE-SET.
rule-providers:
reject:
type: http
behavior: domain
url: "https://example.com/rules/reject.txt"
path: ./ruleset/reject.yaml
interval: 86400
rules:
- RULE-SET,reject,REJECT
- GEOIP,CN,DIRECT
- MATCH,PROXY02The Three behavior Types
behavior tells Clash how to parse the contents of a rule set. Get this wrong and the whole rule set silently stops working — it's the field people mess up most often.
| behavior | Rule set content format | Typical use |
|---|---|---|
| domain | A plain list of domains, one domain or domain suffix per line | Ad-domain blocklists, per-site routing lists |
| ipcidr | A plain list of IP ranges, one CIDR block per line | Country-level IP ranges, specific cloud provider IP ranges |
| classical | Full rule statements without a final action, e.g. DOMAIN-SUFFIX,x.com | Mixed rule types, more flexible custom rule sets |
The type Field: http or file
type: http pulls periodic updates from a remote URL and is by far the most common choice. type: file uses a local rule set file directly — useful if you maintain your own list and don't need it to update over the network.
03Common Rule Set Sources
Well-known community projects include the domain-classified GeoSite series, and various "ACL4SSR"-style rule collections. These typically ship both domain and classical format files — check the project's official repository for the exact links, and make sure the behavior you set matches the file format you're actually pulling.
04Why a Rule Set Might Not Be Working
- behavior doesn't match the file format: for example, if the remote file is actually a plain domain list but you set behavior: classical, the core will either throw an error or silently ignore the rule set.
- Stale local cache at path: if you change the url but a stale copy is already cached locally, some clients won't overwrite it automatically — delete the file at path and force a re-fetch.
- interval set too long: the update interval (in seconds) being too long leaves the rule set stuck on an old version for a long time. 43200–86400 (12–24 hours) is a reasonable default for everyday use.
05Can You Mix Rule Provider With Regular Rules?
Yes, and this is by far the most common setup. RULE-SET references and ordinary rules (like DOMAIN-SUFFIX or GEOIP) can be freely interleaved in your rules list — the core still processes them top to bottom and stops at the first match, regardless of where each rule came from. In practice, people usually put a few commonly used rule sets (ad blocking, regional routing, etc.) near the top, sprinkle in a handful of hand-written domain rules in the middle, and finish with a catch-all rule at the bottom. Mixing both approaches is genuinely the least effort in the long run.
06Should You Maintain Your Own Rule Set File?
For the vast majority of people, no. Community-maintained rule sets already cover the common cases — ad blocking, regional site classification, and so on — and they're kept up to date for you, so referencing them directly is enough. It's only worth setting up your own with type: file and a local file if you have a genuinely specific routing need (internal company domains, or a personal list you maintain long-term) that isn't suited to sharing publicly. For everyday use, a few hand-written rules or the ordinary entries in rules are already more than sufficient.