If you already have a working configuration and want to change how traffic is routed, first check in Home that Global Routing is set to Config, then edit the [Rule] section of the active configuration. Put specific exceptions before broader rules, keep FINAL at the end, and test with requests that match an exception, a general rule, and the fallback.
Rules are evaluated line by line, not by specificity
When routing traffic by configuration, Shadowrocket checks the [Rule] section from top to bottom. The first rule that matches determines the request's policy. Adding a more specific rule at the bottom does not give it higher priority; if an earlier rule already matches the request, later rules are not evaluated.
For example, DOMAIN-SUFFIX,example.com,DIRECT matches example.com and its subdomains. If this line comes before DOMAIN,blocked.example.com,REJECT, requests to blocked.example.com match DIRECT first, so the reject rule below it never takes effect. To reject that host while allowing other hosts under the same suffix, move the specific DOMAIN rule above the suffix rule. By contrast, notexample.com ends with the same characters but is not example.com or one of its subdomains.
Ordering DOMAIN, DOMAIN-SUFFIX, and IP-CIDR rules
A typical rule line contains the rule type, match value, and policy, separated by commas. DOMAIN matches an exact hostname, DOMAIN-SUFFIX matches a domain and its subdomains, and IP-CIDR matches an IPv4 address range. For domain rules, enter only the hostname—no https://, port, or path. Domain rules cannot distinguish between two URL paths on the same host.
[Rule]
DOMAIN,blocked.example.com,REJECT
DOMAIN-SUFFIX,example.com,DIRECT
IP-CIDR,192.0.2.0/24,DIRECT,no-resolve
FINAL,PROXY
The examples use reserved domains and documentation address ranges for illustration only; they are not for testing public internet connectivity. When editing, add rules to the existing [Rule] section. Do not add a duplicate section header or place rules after the existing FINAL rule.
- For a request to
blocked.example.com, when the hostname is available for matching, the first line returnsREJECT. Forwww.example.com, the second line returnsDIRECT. - A request directly to
192.0.2.10can match192.0.2.0/24. In this example,no-resolvemeans Shadowrocket will not actively resolve a domain just to match this rule; it does not disable DNS. If there is a domain but no IP available for matching, this rule cannot match based on the domain alone. - If an exact address overlaps with a larger subnet, put the single-address exception (use
/32for IPv4) before the broader subnet rule. For broad IP rules such asGEOIP, also check whether they might match before a subnet rule that needs priority.
Choose FINAL based on how unmatched traffic should be handled
FINAL takes only a rule keyword and a policy, with no domain or subnet in between. It handles requests that did not match any preceding rule; it is not a retry option for failed connections. If a rule matches PROXY but the proxy connection fails, the request does not continue down to FINAL,DIRECT.
FINAL,DIRECT- Unmatched requests go direct. This suits configurations that send only explicitly listed destinations through a proxy. New domains that are not added to the rules will also go direct.
FINAL,PROXY- Unmatched requests go through the proxy. This suits setups where direct and rejected exceptions are explicitly defined and all other requests use the existing proxy configuration. Unlisted local services may also be routed through the proxy, so check which direct rules need to remain before making changes.
FINAL,REJECT- Reject unmatched requests. This suits controlled configurations with an explicit allowlist. When testing, include dependencies such as login redirects and static assets: allowing the main domain does not mean those requests are allowed too.
Set Global Routing to Config to test rules
Check the current mode under Home → Global Routing. Here, Proxy and Direct refer to global modes; PROXY and DIRECT in rules describe what happens when a particular rule matches. These are different levels and should not be conflated when determining how a request is routed.
Config
RecommendedUse the active configuration to match rules. The first matching rule and FINAL determine whether each request is proxied, sent direct, or rejected.
Best for: Testing custom rules, exception priority, and fallback behavior.
Proxy
Route intercepted traffic through the proxy without following the rule branches in the example. Use this to check whether a destination is reachable through your existing proxy, but not to verify whether FINAL is configured correctly.
Best for: Temporarily checking reachability through the proxy path.
Direct
Send intercepted traffic direct without following the rule branches in the example. When using this for comparison, the REJECT rule does not override the direct mode.
Best for: Temporarily comparing results over your current direct connection.
If you were using Scene, note the current mode first, then switch to Config for comparison so that scene conditions do not affect the results. Restore the previous mode afterward if needed.
Save the configuration, then test with new requests
Confirm the active configuration
Open
Config, note the filename of the configuration in use, and keep a copy before editing. If the list contains files with identical or similar names, the filename alone is not enough to tell which one is active.Reorder the rules
In
Config, tap ⓘ next to the target file and chooseEdit Config. Move specific exceptions above the suffix or subnet rules that would otherwise match them, then check thatFINALis at the end. After saving, confirm that you are using the edited file.Switch the routing mode
Go to
Home → Global Routing → Configand confirm the connection is on. To check the proxy branch, use a working configuration you already have.Home → Connectivity Testcan help diagnose connection issues, but it does not show which rule matched a particular destination.Test all three branches
Use test destinations you control and know are reachable. Send new requests that match a specific exception, a general rule, and
FINAL, respectively. If connection logs show match details, check the destination, rule, and policy for each request. Do not draw conclusions solely from whether a page opens in the browser.
Before testing, you can close existing connections and send new requests to avoid reusing established connections. A webpage often contacts multiple hosts: if the main page loads but images or login fail, check the hostname of the failed request rather than only the domain in the address bar. Change one thing per test—for example, swap only two rules—then retest the same destination to distinguish a rule-order change from a connection-condition change.
Common issues: Rules are in place, but nothing changes
Why does a site still open even though I added a reject rule?
First check that Home → Global Routing is set to Config, then see whether a DOMAIN-SUFFIX rule above the reject rule already matches the destination. If so, move the specific reject rule above it, save, and send a new request.
Why does the IP match, but the domain name does not, for the same server?
A domain request may match an earlier domain rule first. Also, an IP-CIDR rule with no-resolve will not actively resolve the domain for that rule. To apply the same policy to a known hostname and IP address, add separate DOMAIN and IP-CIDR rules, then check whether either is already covered by an earlier rule.
Why does changing FINAL leave a destination on the same policy?
First check whether an earlier rule matches the destination. Test the fallback with a destination that is clearly outside all preceding rules. If it still behaves unexpectedly, check which configuration file is active and review Global Routing.
Why did my new rule disappear after the configuration refreshed?
Check whether you edited a local copy or a configuration that gets replaced by remote content. Keep a copy before updating. If an update overwrites your changes, merge any rules you need to retain into a local copy, check their order, and switch to that copy to test.