FlClash Get FlClash

Routing you can maintain, with rule providers

Thousands of copied DOMAIN-SUFFIX lines go stale in months. Three self-updating rule sets leave you with five lines.

Published , about 4 min

Many profiles run to ten thousand lines, nine tenths of them rules. They worked when copied, then sites changed domains and nobody dared delete anything. Rule providers fix that: someone else maintains the list and your profile only says where to get it.

Nothing advanced: rules go out of date and you do not want to edit daily. Leave it to those who keep lists, and keep only your own few.

The finished thing

Three sets, for Chinese domains, Chinese IPs and ads:

rule-providers:
  cn_domain:
    type: http
    behavior: domain
    format: mrs
    interval: 86400
    url: https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/cn.mrs
  cn_ip:
    type: http
    behavior: ipcidr
    format: mrs
    interval: 86400
    url: https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geoip/cn.mrs
  ads:
    type: http
    behavior: domain
    format: mrs
    interval: 86400
    url: https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/category-ads-all.mrs

And five rules:

rules:
  - IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
  - RULE-SET,ads,REJECT
  - RULE-SET,cn_domain,DIRECT
  - RULE-SET,cn_ip,DIRECT,no-resolve
  - MATCH,PROXY

Replace PROXY with your group's exact name. Outside China, use your own country's IP file, such as geo/geoip/jp.mrs, and drop the domain set if there isn't one for you.

What each line does

  1. type: httpDownload from an address. file means a local file
  2. behavior: domainOnly domains inside. ipcidr means only ranges, classical a mix
  3. format: mrsmihomo's binary format, small and quick to load. The Chinese domain list is just 520 KB
  4. interval: 86400Update every 86400 seconds, once a day
  5. urlThe file. These come from meta-rules-dat by MetaCubeX

A wrong behavior is the usual mistake. Give a domain file ipcidr and the set fails to load while later rules keep working, so nothing looks broken and sites meant to go direct all use the proxy.

Why this order

Local addresses first, so your printer and router don't go abroad. Ads second, to stop them early. Domains before IPs, since matching a domain needs no lookup. no-resolve after cn_ip keeps it to requests that are already IPs. MATCH catches the rest.

Check the Requests page afterwards. Every connection shows the rule it matched.

Into FlClash

Don't edit the subscription file, because the next update wipes it. Put both blocks in the profile's override, with your rules ahead of the subscription's, for reasons discussed in 2251.

The sets are downloaded from GitHub the first time. If you aren't connected yet that may stall, so connect with the subscription's own rules first.

Connect with the subscription's own rules first, then add your override.

More branches

For streaming or AI sites, repeat the pattern: one more set, one more RULE-SET, pointing to a new group. The geo/geosite folder of meta-rules-dat is sorted by site, and the file name is the name.

Don't overdo it. Each addition means checking whether it overlaps the earlier ones. Three to five is plenty for most people.

A separate Streaming group for the rule set to point to.
A separate Streaming group for the rule set to point to. Image: FlClash, GPL-3.0

Test the change

Misspelled rules and missing groups show up at once in the Profile checker. To see where a domain stops, use the Rule tester, which can't look inside rule sets and marks them unknown.

Moving from a bloated file

  1. Back up.
  2. Count DOMAIN-SUFFIX; hundreds were copied from somewhere.
  3. Keep your own, usually under twenty.
  4. Replace the rest with the three sets and five rules above.
  5. Yours on top.
  6. Use it a week.

From ten thousand lines to sixty, quicker and lighter.

Groups for sites

proxy-groups:
  - name: Video
    type: select
    include-all: true
    filter: "(?i)HK|JP|SG"
  - name: AI
    type: select
    include-all: true
    filter: "(?i)US"
rule-providers:
  openai:
    type: http
    behavior: domain
    format: mrs
    interval: 86400
    url: https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/openai.mrs
rules:
  - RULE-SET,openai,AI

include-all takes all nodes, filter selects by name without regard to case. Common sets: openai, youtube, netflix, telegram, github, google, apple, microsoft, steam.

Three behaviours

ContentsbehaviorExample
Domainsdomain+.example.com
Rangesipcidr1.1.1.0/24
Whole rulesclassicalDOMAIN-SUFFIX,example.com

mrs supports the first two. Errors show in the log under provider.

Your own

  1. FileOne domain a line, txt
  2. Declaretype: file, behavior: domain, format: text
  3. UseRULE-SET,name,DIRECT
  4. Several devicesIn your Git as type: http

It does not download

Connect with the old rules first; add proxy: group to the provider; or use a mirror. Afterwards it is cached.

How often

A day. Minutes waste traffic, a year is never. If something is wrong one day, see whether the list just changed.

Also asked

How is this different from geosite?

GEOSITE,cn reads one big data file with everything in it. A rule set downloads only what you ask for, uses less memory and updates on its own schedule.

Can ad rules break sites?

Yes. Some login buttons sit on a blocked domain. If something won't open, look for REJECT on the Requests page.

Do many sets slow it?

domain and ipcidr are quick at tens of thousands; classical is not.

Overlaps?

The earlier wins.

What is inside?

mrs is binary; the same folder has list and yaml.

Read next

On the same line

Key terms: Clash rule-providers, Clash rule sets, Clash ad block rules