If you already use your own configuration or subscription in Shadowrocket, set Global Routing on Home to Config first, then check the active configuration’s [Rule] section: put host-specific exceptions before suffix rules that cover them, place exceptions before overlapping network ranges, and leave FINAL at the end. The walkthrough below uses a configuration you can trace line by line to explain how to choose a default policy and verify which rule actually matched.
Rule Priority: The First Match Wins
When traffic reaches Shadowrocket with Home → Global Routing set to Config, the active configuration determines how it is routed. The first matching rule in [Rule] decides the action. Shadowrocket does not compare every match and then choose the longest domain or narrowest network range. Place exceptions before broader rules; an exception listed afterward cannot override an earlier match.
First, distinguish the routing modes in the interface from the policies at the end of rule lines. Proxy and Direct are Global Routing modes: they send the traffic they handle through a proxy or directly, without applying the active [Rule] entries one by one. PROXY, DIRECT, and REJECT can appear at the end of a rule and apply only to traffic that matches that rule. To troubleshoot a specific configuration, select Config explicitly; don’t use Scene, which applies according to the active scene, as a substitute.
DOMAIN-SUFFIX and IP-CIDR Syntax
DOMAIN-SUFFIX,example.com,PROXY matches example.com and its subdomains, such as www.example.com, but not notexample.com. Enter the domain suffix without https://, a port, or a path. To make an exception for one host, use an exact DOMAIN match and place it before any DOMAIN-SUFFIX rule that covers that host.
IP-CIDR,192.0.2.0/24,DIRECT matches destination IPv4 addresses from 192.0.2.0 through 192.0.2.255. To match just one address, use /32; 192.0.2.10/32 matches only 192.0.2.10. This IP-CIDR rule does not distinguish TCP ports 80 and 443 on the same IPv4 address. For requests made with a domain name, whether an IP rule matches also depends on the destination address available at match time and DNS resolution conditions; the browser’s address bar alone isn’t enough to tell.
Put Domain Exceptions First
DOMAINblocked.example.com,REJECTDOMAIN-SUFFIXexample.com,PROXY- Overlapping targets
blocked.example.com
Place the exact match first so only the specified host is blocked by this exception.
Put Single-IP Exceptions First
IP-CIDRsingle address192.0.2.10/32,REJECTIP-CIDRnetwork range192.0.2.0/24,DIRECT- Overlapping targets
192.0.2.10
Put the /32 exception first, then the /24 range that includes it.
FINAL Fallback and Policy Order
FINAL takes no domain or network range; write it as a two-field rule such as FINAL,DIRECT. The example below starts with “proxy only the explicitly listed suffixes; send everything else direct.” The domains and addresses illustrate rule order only. They don’t need to return a webpage, and you don’t need to add any connection details to the configuration.
[Rule]
DOMAIN,blocked.example.com,REJECT
DOMAIN-SUFFIX,example.com,PROXY
IP-CIDR,192.0.2.10/32,REJECT
IP-CIDR,192.0.2.0/24,DIRECT
FINAL,DIRECT
| Request target | First matching rule | Action |
|---|---|---|
blocked.example.com | DOMAIN | REJECT: Reject the connection; do not retry via proxy or direct. |
www.example.com | DOMAIN-SUFFIX | PROXY: Connect through the currently selected proxy. |
192.0.2.10 | IP-CIDR /32 | REJECT: This address is also within the /24, but matching stops here. |
192.0.2.20 | IP-CIDR /24 | DIRECT: Connect to the destination without a proxy. |
198.51.100.20 | FINAL | DIRECT: No earlier rule matched. |
Choose the Default Route for Unlisted Targets
To proxy only explicitly listed targets, use FINAL,DIRECT. To proxy unlisted targets too, use FINAL,PROXY and put any destinations that must connect directly in exceptions above it. Choose FINAL,REJECT only if all unlisted connections should be blocked, and first list every domain and address the apps you use require.
The ordering principle here is not to put every REJECT above DIRECT or PROXY. Only rules with overlapping match ranges and different actions need priority ordering. FINAL is not a retry fallback: if a rule matches and selects PROXY, a failed proxy connection does not cause the request to fall through to FINAL,DIRECT.
Edit Rules in Config and Verify Matches
Keep a copy of the configuration before editing, then make changes in a test copy. If the active configuration is updated remotely, check whether an update replaces the entire file so your local changes aren’t overwritten next time. A provider’s connection subscription and the configuration file that routes traffic are separate: the former supplies details for existing proxies, while the latter determines which requests use them.
- Confirm which configuration you’re editing. In Config, find the active configuration and edit a copy of its
[Rule]section. When merging changes into an existing configuration, don’t paste in a duplicate[Rule]header. Find the existingFINAL, insert new rules in the right places, and keep just one fallback at the end. - Activate the edited configuration. Save it, select it in Config, then return to Home and confirm that the connection is on and Global Routing is set to
Config. If you save a file without selecting it, your tests may still use the old rules. - Test an exception with a new connection. Choose a host you can access and another host under the same suffix, then test the exact-match and suffix rules separately. Close any pages or apps that might reuse an existing connection before trying again. Don’t assume the new rule failed just because you refreshed a page that was already open.
- Check the destination and action. Find the request you just made in the connection log and check its actual destination, policy, and any match details shown in the interface. If a page loads content from multiple domains, check the main page request and failed resource requests separately. A page loading successfully doesn’t mean every resource used the same rule.
If both the rule you’re testing and the fallback are DIRECT, a page loading successfully won’t tell you whether the network rule matched or traffic reached FINAL. Check any match details available first. To distinguish the two, temporarily set REJECT for a single target you control in a test copy. Confirm that a new connection is rejected as expected, then restore the intended policy.
Common Rule Troubleshooting Questions
I added the new rule at the end. Why doesn’t it work?
If the new line is after FINAL, move it above it. Then check the rules above it for a suffix, network range, or rule set that covers the same target. If an earlier rule already assigns a policy, move the exception above that broader rule, then test with a new connection.
I only want to block one subdomain. Why is the whole site unavailable?
First, check whether you used DOMAIN-SUFFIX,example.com,REJECT by mistake. To block only blocked.example.com, use DOMAIN,blocked.example.com,REJECT instead. If other pages still fail, check whether they rely on that host for sign-in, images, or API requests.
It connected automatically in the background. Why isn’t traffic following my rules?
Check the automatic connection settings under Settings → On Demand. They control when a connection is established, not which rules it uses. Return to Home to check Global Routing, then confirm in Config that the selected file is the one you just saved.
The connection shows PROXY, but the request times out. Should I change FINAL?
Don’t change FINAL yet. If the connection is using PROXY as intended, check which proxy is selected on Home and test another known-accessible destination using the same proxy. If only one destination fails, troubleshoot domain resolution and reachability of the destination service separately. A failed proxy connection doesn’t mean the rule failed to match.