Clash Verge Custom Rules: DOMAIN-SUFFIX, GEOIP, and MATCH Order
Learn how mihomo evaluates rules from top to bottom, how to use DOMAIN-SUFFIX, GEOIP, and MATCH, and how to troubleshoot common syntax mistakes.
Confirm the configuration is active before changing rules
- Open Subscriptions in Clash Verge Rev and confirm which configuration is selected. Keep the original configuration and test with a local copy. If you use a rules override, check the resulting order—not just the original subscription.
- Open Proxies and switch the mode to Rule. This section covers how mihomo matches
rulesin Rule mode. In Global or Direct mode, you can’t use the order below to predict where traffic will go. - Save and apply the configuration, then start a new connection. Existing connections may continue using their previous policies, and a browser refresh may reuse an existing connection. To compare results, close the relevant connection first, then send a new request.
The client manages and applies the configuration; the mihomo core evaluates the rules one by one. System proxy and TUN mode determine how traffic reaches the core, not which rule comes first. If an app uses neither the system proxy nor TUN, changing rules won’t affect its traffic.
How to write DOMAIN-SUFFIX, GEOIP, and MATCH rules
rules is a YAML list. Most rule entries follow the format “type, match value, policy,” with fields separated by commas. MATCH doesn’t need a match value. For IP-based rules such as GEOIP, you can add no-resolve after the policy.
| Rule entry | What it matches | Example |
|---|---|---|
DOMAIN,api.example.com,DIRECT | Exact domain | Matches api.example.com, but not cdn.api.example.com. |
DOMAIN-SUFFIX,example.com,REJECT | Domain suffix | Matches example.com and img.example.com, but not notexample.com. |
GEOIP,CN,DIRECT | Geographic classification of the destination IP | Matches when the destination IP is classified as CN by the current GeoIP data. |
MATCH,DIRECT | No additional conditions | Handles connections that reach this rule without matching any earlier rule. |
DIRECT sends traffic directly; REJECT blocks it. To route traffic through a proxy group, use the exact group name from the active configuration. Node names, subscription names, and policy group names are different things. Check the configured name exactly, including spaces, capitalization, and emoji.
Rule order: exceptions first, broader matches next, fallback last
For the rule types below, mihomo checks the final configured list from top to bottom and applies the policy of the first matching rule. The core won’t automatically put DOMAIN before DOMAIN-SUFFIX, or go back to choose a more specific match.
rules:
- DOMAIN,api.example.com,DIRECT
- DOMAIN-SUFFIX,example.com,REJECT
- IP-CIDR,192.0.2.0/24,DIRECT,no-resolve
- GEOIP,CN,DIRECT,no-resolve
- MATCH,DIRECT
This snippet illustrates rule order; it isn’t a complete subscription. example.com and 192.0.2.0/24 are documentation examples; the latter isn’t a connectivity test target. Make any needed changes in a test copy, rather than replacing the entire rules list in your existing subscription.
- If the destination hostname seen by the core is
api.example.com, the first rule matches and the result isDIRECT. The core won’t check the second rule, even though it would also match this domain. - For
img.example.com, the first rule doesn’t match, but the second one does, so the result isREJECT. If you swap the first two rules,api.example.comwill also be rejected. - If the destination reaches the core directly as the IP address
192.0.2.12, the first two domain rules don’t apply. The third rule checks the subnet and matches. Other known IPs classified asCNmay match the fourth rule. - The fifth rule applies only if the first four don’t match. In this example, rules three, four, and five can all result in
DIRECT. To verify the outcome, check which rule matched—not just whether the page loaded or traffic went direct.
When adding an exception for a single domain, check for earlier RULE-SET entries. If a rule set already covers the domain, adding the exception after it is too late. If your override tool offers prepend or append options, place the exception before the rule it needs to override. Appending a rule after an existing MATCH won’t work.
GEOIP and no-resolve: check whether the core has the destination IP
GEOIP,CN,DIRECT checks the destination IP—not your location or the domain suffix. A .cn domain may resolve to an address not classified as CN. The same domain may also use different policies when DNS results or CDN routing change. To keep a domain’s routing consistent, put its domain rule before GEOIP.
- Without
no-resolve: When evaluation reaches this rule, the core may resolve the hostname for IP matching if it has a domain but no usable destination IP. Whether the rule matches depends on the DNS result and current GeoIP data. - With
no-resolve: This rule won’t resolve a hostname for matching. If a usable destination IP is available, it can still be checked; otherwise, this rule is skipped. This isn’t a global DNS switch, and it doesn’t prevent later rules or the actual connection from triggering DNS resolution.
When troubleshooting, first check whether the request uses a domain or an IP address. If you access the same service by IP and the core doesn’t have a domain available for rule matching, DOMAIN-SUFFIX can’t match. Conversely, seeing a domain in the request doesn’t prove that GEOIP will be skipped: the core may already have a usable destination IP.
Custom rules not working? Check loading, traffic capture, and rule matches
1. Fix configuration loading errors first
Check that rules: is at the top level, list indentation is consistent, commas are standard ASCII, and the policy names exist. When editing a full configuration, add rules to the existing rules list; don’t create a second top-level key with the same name. If you use rule sets, make sure each RULE-SET reference matches a key in rule-providers.
2. Confirm the request reaches the core in Connections
Return to Connections, send a new request, and check its destination domain or IP. If there’s no matching entry, first check whether the app uses the system proxy or its traffic is captured by TUN. If the app requires a manually configured proxy port, use the mixed port shown in the client. Enter 127.0.0.1:7897 only if the configured port is actually 7897. Confirm traffic capture before investigating rule order.
3. Check which rule matched, not just the exit route
In Connections, check the connection’s matched rule and policy chain. If the list doesn’t provide enough detail, check Logs. A page may also load images, scripts, or sign-in endpoints, so the main site matching a rule doesn’t mean those requests match it too. Compare the actual destination with the final rule list and find the first matching rule from the top.
- An unexpected earlier rule matched: Move the more specific exception above it, save, and test with a new connection.
- Traffic falls through to
MATCH: Check domain boundaries, the destination the core actually sees, and whetherno-resolvecaused an IP rule to skip this request. - Changes disappear after updating the subscription: Check whether you edited a local copy of the remote configuration directly. Keep personal rules in a separate rules override, then verify the final order after each update.