Rules

Rules explains TYPE, ARGUMENT, POLICY matching, common rule types, ordering strategy and checks for unexpected routing behavior.

Overview

Rules are the part of a Clash profile that decide where each request should go. A rule normally follows the pattern TYPE,ARGUMENT,POLICY, with an optional no-resolve flag for rule types that would otherwise trigger DNS resolution.

The policy can be DIRECT, REJECT, a proxy name, or a proxy group. In day-to-day profiles, rules are usually ordered from specific to broad, and the final rule is normally MATCH.

Common rule types

  • DOMAIN matches one exact domain.
  • DOMAIN-SUFFIX matches a domain and all of its subdomains.
  • DOMAIN-KEYWORD matches domains containing a keyword.
  • GEOIP, IP-CIDR and IP-CIDR6 match resolved IP addresses or address ranges.
  • PROCESS-NAME and PROCESS-PATH match the application that initiated traffic when supported by the operating system.
  • RULE-SET and SCRIPT are advanced or Premium-style matching mechanisms.
  • MATCH catches everything that has not matched earlier rules.

Examples

Put exact and high-priority rules first. Put broad rules such as GEOIP and MATCH near the end, otherwise they can prevent later rules from being reached.

Support Checks

If Rule mode does not behave as expected, check whether the request matches an earlier rule, whether the selected policy group has an available node, and whether DNS settings are forcing a different host or IP path.

Reference examples

These examples mirror the corresponding Chinese documentation page so the English page carries the same configuration material.

# TYPE,ARGUMENT,POLICY(,no-resolve)
TYPE,ARGUMENT,POLICY(,no-resolve)