Shadowrocket Custom Rules and Rule Priority: Top-to-Bottom Matching, FINAL Fallback, and PROXY/DIRECT/REJECT Strategies

Learn how Shadowrocket matches rules from top to bottom, orders DOMAIN-SUFFIX and GEOIP, uses FINAL as a fallback, and applies PROXY, DIRECT, and REJECT.

At a Glance

This guide is for users who have already imported their own configuration into Shadowrocket and need to adjust routing results. It explains how requests hit rules, how to order specific and broad rules, when to use PROXY, DIRECT, or REJECT, and how FINAL handles unmatched requests.

The Core of Rule Priority: Stop at the First Match

Shadowrocket does not evaluate the entire rule list and then choose the “most specific” match. It checks rules one by one from top to bottom in the order written in the configuration. Once a rule matches the current request, later rules are skipped. Priority is therefore determined by position—not automatically by the rule name, character length, or strategy type.

For example, the same domain may match both an exact DOMAIN rule and a DOMAIN-SUFFIX rule covering the entire suffix. If DOMAIN-SUFFIX comes first, the more specific DOMAIN rule will never take effect. Put exceptions before broad rules, and place the broadest fallback at the end.

Request startsRead domainMatch rules in orderFirst matchApply strategy

A typical decision can be broken into five steps: an app starts a connection; Shadowrocket obtains the destination domain or IP; checking begins at the first line of [Rule]; the process stops at the first matching rule; and the strategy at the end of that line is applied. If no specific rule matches, processing continues to FINAL.

[Rule]
DOMAIN,api.example.com,DIRECT
DOMAIN-SUFFIX,example.com,PROXY
IP-CIDR,192.168.0.0/16,DIRECT
GEOIP,CN,DIRECT
FINAL,PROXY

When accessing api.example.com in this example, the first line matches and uses DIRECT. When accessing www.example.com, the first line does not match, so DOMAIN-SUFFIX matches next and uses PROXY. A destination in the private range 192.168.0.0/16 uses DIRECT; remaining requests go through GEOIP and any still unmatched are passed to FINAL.

How to Order DOMAIN, DOMAIN-SUFFIX, IP-CIDR, and GEOIP

Order rules from “narrow scope, clear intent” to “broad scope, wide coverage.” DOMAIN matches one complete domain and is useful for individual exceptions; DOMAIN-SUFFIX covers the specified domain and its subdomains; IP-CIDR matches an address range; and GEOIP classifies the destination IP using geographic data. FINAL does not inspect a specific destination—it receives every request not matched earlier.

1 rule
Each request uses only the first matching rule
4 routing modes
Global Routing:Config / Proxy / Direct / Scene
3 strategies
This guide uses PROXY / DIRECT / REJECT
1 final line
Usually keep one FINAL and place it at the end

Recommended Rule Order

  1. Local and reserved addresses: Handle LAN addresses and destinations that clearly require DIRECT first, so requests to internal devices do not fall through to other strategies.
  2. Exact domains: Use DOMAIN for special handling of a single host—for example, letting one API domain override a later suffix rule.
  3. Domain suffixes: Use DOMAIN-SUFFIX for a root domain and all of its subdomains.
  4. Address ranges: Use IP-CIDR to match a specific IPv4 network. A longer prefix generally covers a narrower range.
  5. Geographic classification: Put GEOIP after specific domain and address rules, so broad classification does not capture exception requests first.
  6. Final fallback: Put FINAL last to define how all remaining traffic is handled.

Specific Rules

DOMAIN
api.example.com,DIRECT
DOMAIN-SUFFIX
example.com,PROXY
IP-CIDR
192.168.0.0/16,DIRECT

Write exceptions before rules with broader coverage.

Broad Rules

GEOIP
CN,DIRECT
FINAL
PROXY
Position
End of [Rule]

Complete specific matching first, then apply geographic classification and the final fallback.

The value of DOMAIN-SUFFIX should contain only the domain name—never https://, a path, or query parameters. Rules match hostnames, not complete web addresses. To handle cdn.example.com, use DOMAIN,cdn.example.com,DIRECT; to cover example.com and all levels of its subdomains, use DOMAIN-SUFFIX,example.com,PROXY.

The prefix length in IP-CIDR must match the target network. For example, 192.168.0.0/16 covers addresses from 192.168.0.0 through 192.168.255.255. If it is mistakenly written as /24, the range narrows to one subnet, so other similar LAN addresses will not match.

Conclusion: The More Specific the Exception, the Earlier It Goes

A single domain, address range, or LAN exception that must override a general rule should come before DOMAIN-SUFFIX, GEOIP, and FINAL. Making a rule more specific does not automatically give it higher priority.

What PROXY, DIRECT, and REJECT Change

The strategy at the end of a rule determines how a matched request is handled. PROXY passes it to the proxy strategy selected in the current configuration; DIRECT connects to the destination directly; REJECT refuses the request. These are handling actions, not rule keywords. DOMAIN-SUFFIX, GEOIP, IP-CIDR, and similar entries decide “what matches,” while the final strategy decides “how it is handled.”

Strategy Result Suitable Rule Intent What to Check
PROXY Pass the request to the proxy strategy in the configuration Domains that clearly need a proxy path, or a FINAL fallback Confirm the selected strategy is available and Global Routing is set to Config
DIRECT Connect directly to the destination from the current network LAN addresses, explicitly direct domains, or GEOIP classifications Confirm the local network can reach the destination directly
REJECT Reject the matching request immediately Clearly defined domains or address ranges that should be blocked Do not accidentally set an overly broad suffix to REJECT

PROXY does not guarantee that every request will succeed; it only passes the request to the currently selected proxy strategy. The final result still depends on the user’s existing configuration, protocol parameters, and network conditions. Shadowrocket configurations may include protocols such as Shadowsocks, VMess, VLESS, Trojan, Hysteria2, or WireGuard, but rule order is independent of the specific protocol: changing protocols does not alter the top-to-bottom matching behavior of [Rule].

DIRECT does not mean “bypass Shadowrocket.” The request still goes through rule evaluation first; DIRECT only determines that it should exit directly after a match. If a LAN device cannot be reached, check that the private-address rule appears before FINAL and that Global Routing is not left on Proxy.

REJECT should be limited to clearly defined targets. If DOMAIN-SUFFIX,example.com,REJECT appears first, the root domain and all subdomains will be rejected, even if DOMAIN,api.example.com,DIRECT appears later. Write the allowed exception first, followed by the broader rejection rule.

Allowed Exception

First Line
DOMAIN,api.example.com,DIRECT
Second Line
DOMAIN-SUFFIX,example.com,REJECT
Result
Direct connection for the API; reject the remaining suffix

The exact DOMAIN matches first and therefore overrides the later suffix rule.

Routing Mode

Config
Route by the rule list
Proxy
Use the global proxy mode
Direct
Use the global direct mode
Scene
Choose the mode according to the configured scene

When troubleshooting custom rules, verify Global Routing in Home first.

Why FINAL Must Be at the End of the Rule List

FINAL is the common exit for unmatched requests. It does not limit a domain, IP, or address range, so placing it in the middle catches every request not matched earlier and leaves later rules with no opportunity to run. Even if the configuration allows additional lines after FINAL, those lines cannot change the first match that has already been completed.

# Recommended order
DOMAIN,internal.example.com,DIRECT
DOMAIN-SUFFIX,example.com,PROXY
GEOIP,CN,DIRECT
FINAL,PROXY

# Incorrect order
FINAL,PROXY
DOMAIN,internal.example.com,DIRECT

The first sequence checks the exact domain, suffix, and GEOIP rules before using PROXY for the remaining requests. In the second sequence, FINAL matches every request on the first line, so the second line never gets a chance to work. If a newly added rule appears to have no effect, first check whether it was placed after FINAL.

The strategy used by FINAL should reflect the configuration’s goal, rather than being fixed mechanically. If the structure is “list direct exceptions and proxy everything else,” use FINAL,PROXY. If it is “list only destinations that need a proxy and connect directly to everything else,” use FINAL,DIRECT. Both structures are valid, but the preceding rules must align with the fallback direction.

Conclusion: Decide the Default Behavior Before Writing Exceptions

First decide whether unmatched requests should ultimately use PROXY or DIRECT, then place exceptions that oppose the default behavior before FINAL. This is easier to review than continually adding duplicate rules and prevents conflicting handling for the same domain.

Verify Changes with a Consistent Checklist

  1. In Config, open the configuration currently in use and confirm that the edit was made there—not in another configuration with the same name or in a backup copy.
  2. Check whether [Rule] contains only one FINAL serving as the fallback, and confirm that it is the last rule in the list.
  3. Return to Home and set Global Routing to Config. If it is set to Proxy or Direct, the expected custom-routing result cannot be tested in Config mode.
  4. Test one destination that should match DIRECT and another that should match PROXY. Do not use a single website to judge the entire rule set.
  5. If the result differs from expectations, start at the top of the rule list and look for the first DOMAIN, DOMAIN-SUFFIX, IP-CIDR, or GEOIP rule that could match, rather than checking only the line you just added.

Configuration Updates, On Demand, and Common Reasons Rules Do Not Take Effect

When users have their own provider and subscription, a configuration update may write the provider’s remote rule content again. If custom rules were edited directly in a configuration that is overwritten by updates, refreshing may restore the remote content. Before editing, determine whether the current configuration is maintained manually or updated through a subscription, then recheck the [Rule] order and FINAL position after each update.

On Demand and rule priority operate at different stages. The entry point is Settings → On Demand; it uses the configured network conditions to decide when to establish a connection. Once connected, request routing still depends on Global Routing and the current configuration rules. If On Demand has not established a connection, changing [Rule] cannot replace checking the connection conditions.

Rule Execution

Entry Point Check
Home → Global Routing
Test Mode
Config
Configuration Location
[Rule] in the current Config
End Point
FINAL on the last line

Confirm the active object first, then determine whether the rule text is correct.

Automatic Connection

Entry Point
Settings → On Demand
Function
Control the connection based on network conditions
Relationship to Rules
Does not change the order of [Rule]
Troubleshooting
Check connection and routing separately

Check connection timing and request strategy as two separate stages.

Another common cause is that the rule contains a URL. DOMAIN and DOMAIN-SUFFIX accept only the domain portion; including the scheme, port, or path makes the match incorrect. For example, to match the host in https://api.example.com:443/v1/status, the DOMAIN value should be api.example.com; port 443 and path /v1/status are not values for that domain rule.

Rule names and strategy names should also use their English originals, with fields separated by English commas. Full-width commas, missing fields, and extra spaces can create invisible differences that prevent a line from parsing as expected. After copying a rule, keep the three-field structure first, then verify the keyword, match value, and strategy one by one.

Why Does a Newly Added DOMAIN Still Use PROXY?

Check whether a matching DOMAIN-SUFFIX already appears above it, then confirm that it was not placed after FINAL. Move the exact DOMAIN intended as an exception before the broad suffix rule, set Global Routing to Config in Home, and test again.

DIRECT Is Set, but the LAN Device Still Cannot Be Opened?

Check whether the destination IP is actually within the IP-CIDR range you entered. For example, 192.168.1.20 matches 192.168.0.0/16 but not 192.168.2.0/24. Then confirm that the local Wi-Fi network itself can reach the device.

Did Custom Rules Disappear After a Subscription Update?

An update may write the current configuration content again. In Config, first confirm which configuration is active and where it comes from, then check whether [Rule] has returned to the updated content. Changes that must persist should use a rule-management method compatible with how that configuration is maintained.

Does Enabling On Demand Change FINAL?

No. On Demand is located at Settings → On Demand and controls connection timing; FINAL remains the fallback at the end of [Rule]. First confirm that a connection has been established, then check whether the request matches the rules in Config mode.

How Can You Quickly Tell Whether REJECT Is Too Broad?

Check the matching keyword before REJECT. DOMAIN affects one complete domain, while DOMAIN-SUFFIX affects the root domain and all subdomains. If only one host should be rejected, use an exact DOMAIN and avoid placing a broad REJECT before necessary exceptions.

Rule Checklist Before Saving

A maintainable configuration usually has clear layers: LAN addresses and exact exceptions first, domain suffixes and address ranges in the middle, GEOIP later, and FINAL at the end. The same destination should not appear repeatedly with conflicting strategies. When an exception is necessary, express it as “specific rule first, general rule later” rather than expecting a later rule to override an earlier one.

After checking, validate with at least two samples in opposite directions: one expected to use DIRECT and one expected to use PROXY. If the configuration includes REJECT, add one clearly rejected destination. Tracing each sample from the top of the rule list to its first match is more useful for finding problems than watching only the connection switch or a single page-load time.

Shadowrocket is a closed-source commercial app for Apple platforms, primarily used on iPhone and iPad. Compatibility and system requirements for Mac, Apple TV, and Apple Vision are as listed on the App Store page. The App Store is the only official source; the developer is listed as Shadow Launch Technology Limited, the app ID is 932747118, and it is sold as a one-time purchase. The app purchase and connectivity services are separate matters; users prepare and manage their own configurations and subscriptions.

Verify the Official Listing View App Store setup instructions