Shadowrocket does not automatically sort rules by specificity. It checks them from top to bottom and applies the policy on the first match. This guide is for users with a working configuration who want to adjust traffic routing. The rule logic applies to iPhone, iPad, Mac, Windows, Android, and Linux; the interface steps refer to Home and Config on iPhone and iPad. By the end, you can arrange rules with exceptions first, broader matches later, and FINAL last, then verify the result with a new connection.
1. Make sure Global Routing is set to Config
If rules aren't behaving as expected, check the active routing mode before rearranging your entire configuration. Open Global Routing in Home and make sure Config is selected, then go to Config and check which configuration is active. Editing or downloading a configuration does not automatically make it the one currently in use.
| Global Routing option | What it does | Troubleshooting use |
|---|---|---|
| Config | Uses rules in the active configuration to choose a policy. | Use this to verify the rule order described in this guide. |
| Proxy | Routes traffic through the proxy rather than checking the routing rules one by one. | Can help check whether the proxy egress works, but does not confirm which rule matched. |
| Direct | Connects directly to destinations. | Can help compare direct connectivity on the current network. |
| Scene | Uses the configured Scene settings. | Check the Scene's linked configuration and conditions first, so a Scene change isn't mistaken for a rule change. |
Settings → On Demand controls when connections are established or disconnected based on conditions. It does not set rule priority for a domain. During troubleshooting, note whether it is enabled, since network changes during testing can affect connection state. Don't repeatedly toggle On Demand instead of checking the active configuration.
2. Rules stop at the first match—specificity is not automatic priority
For each new connection entering rule processing, Shadowrocket checks the matching conditions in the order of the active rules. Once a rule matches, its policy is applied; later rules do not get another vote for that connection. An exact domain rule placed below a broad suffix rule does not automatically take priority.
For example, to send api.example.com through a proxy while connecting directly to other subdomains of example.com, put the exact match first and the suffix match after it. These domains illustrate the syntax; they are not server addresses or a way to test proxy performance.
[Rule]
DOMAIN,api.example.com,PROXY
DOMAIN-SUFFIX,example.com,DIRECT
FINAL,PROXY
api.example.commatches the first rule and usesPROXY.www.example.comdoesn't match the first rule, so it matches the second and usesDIRECT.- The suffix rule also matches
example.comitself. - Other destinations continue down the list until
FINALdecides how to handle them.
If you swap the first two rules, api.example.com matches DOMAIN-SUFFIX first, leaving the exact-match rule no chance to run. A more specific rule only helps when it is in the right position.
3. Know the difference between rule keywords and PROXY, DIRECT, and REJECT
A typical rule has three parts: a match type, a match value, and a policy. The first two determine whether a rule matches; the last determines what happens next. DOMAIN-SUFFIX is a match type, while PROXY is a policy. They serve different purposes.
Match condition
- DOMAIN
- Matches one exact domain, such as api.example.com.
- DOMAIN-SUFFIX
- Matches the domain itself and its subdomains, not any string containing the text.
- IP-CIDR
- Matches based on the destination IPv4 address range.
- GEOIP
- Matches based on the destination IP's geographic database entry.
Domains and IP addresses are different matching criteria. An IP database entry does not necessarily identify where the operator is based.
Policy
- PROXY
- Sends traffic through the proxy egress; a working proxy configuration is still required.
- DIRECT
- Connects to the destination directly over the current network; it does not block the request.
- REJECT
- Rejects matching connections, so a failed connection may be the expected result.
- FINAL
- Not an egress name, but a rule keyword that catches traffic not matched earlier.
Custom policy group names must match the active configuration. This guide uses PROXY, DIRECT, and REJECT to explain the basic behavior.
In short: verify the match, then check the egress
If the record shows the expected rule matched but the destination is still unreachable, check that policy's egress, DNS, and destination connectivity. Don't keep moving a rule that already matches correctly.
PROXY does not refer to a specific protocol. Shadowsocks, VMess, VLESS, Trojan, Hysteria2, and WireGuard are connection or tunneling protocols; changing protocols will not fix a rule hidden by an earlier match. This guide does not change server ports, authentication details, or encryption settings.
4. Copyable rule-order example: exceptions, local networks, geographic matches, FINAL
This minimal rule block illustrates ordering. It handles explicit domain exceptions first, then private IPv4 ranges, and finally the remaining destinations by IP location and default policy. Back up your current configuration before copying. Merge these rules into the existing [Rule] section rather than appending a second section with the same name at the end of the file.
[Rule]
DOMAIN,blocked.example.com,REJECT
DOMAIN,api.example.com,PROXY
DOMAIN-SUFFIX,example.com,DIRECT
IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
GEOIP,CN,DIRECT
FINAL,PROXY
- Put reject exceptions first:
blocked.example.commust come before theexample.comsuffix rule; otherwise, it will match the direct rule first. - Put proxy exceptions next:
api.example.commust also come before the broad suffix rule for the proxy policy to apply. - Handle private addresses separately: These three
IP-CIDRranges cover common private IPv4 addresses, not every special-use address or IPv6. - Place geographic rules later:
GEOIP,CN,DIRECTuses the destination IP's geographic data. It does not replace explicit domain exceptions or guarantee that a particular website will match this rule. - Keep a clear fallback last:
FINAL,PROXYsends traffic through the proxy egress when none of the preceding rules match.
no-resolve means not to trigger a DNS lookup just to check this IP rule. The rule can still match if the destination IP is already available; this does not “turn off DNS.” This example is useful for local network resources accessed by literal IP, such as 192.168.1.10. To reliably connect directly to an internal domain, use internal DNS and add an explicit domain rule above this one.
This is not a complete network configuration
This example contains rules only; it does not include proxy egress, DNS, or policy group definitions. Keep the working parts of your existing configuration. The example domains illustrate matching; replace them with the domains you need to manage, then test each rule.
5. Put FINAL last and choose a fallback policy for your needs
FINAL has no domain or network condition. Common forms include FINAL,PROXY and FINAL,DIRECT; don't write it as FINAL,example.com,PROXY. If placed earlier, FINAL catches the remaining traffic before later regular rules can match, so don't use multiple FINAL rules to express different exceptions.
| Fallback rule | When to use it | What to check |
|---|---|---|
FINAL,PROXY | Send destinations without an explicit routing rule through the proxy by default. | Check whether earlier rules cover internal resources that need a direct connection. |
FINAL,DIRECT | Proxy only explicitly listed destinations; connect directly to everything else by default. | Check that all domains requiring a proxy are included, including login and content subdomains. |
FINAL,REJECT | Allow only connections matched by earlier rules and reject everything else. | Useful for configurations that intentionally maintain an allowlist; missing a required domain will cause access to fail. |
Choose a fallback based on what you want to manage, not on the assumption that one setting is right for every network. A webpage may connect to separate domains for its main site, authentication, images, and APIs. The main site matching the expected rule does not mean every connection on the page uses the same policy. If text loads but images fail, check the destination and matched rule for each failed connection.
6. Edit Config and test with a new connection
First, back up or duplicate the current configuration in Config, then edit the copy. Make sure you are editing the configuration contents, not just changing its display name. Find the [Rule] section, reorder the rules as described above, save, and set that configuration as the active one. Editing screens may differ across platforms; always verify the active file and its rule contents.
- Keep conditions constant: In Home, confirm that the connection is established and Global Routing is set to Config. Use the same network and egress throughout the test.
- Change one thing at a time: Move one rule or change one policy per test. Keep the original order so you can revert if needed.
- Start a new connection: Close and reopen the target app, and reconnect Shadowrocket if needed. Existing long-lived connections may keep their original handling, and a single refresh may not create a new connection.
- Check what matched: Use the connection records or logs available on your platform to verify the destination domain, destination IP, matched rule, and policy. Don't rely only on whether a webpage opens to decide if traffic used a proxy.
- Check dependent requests: If the main domain works but login fails, check the authentication domain. If accessing an IP directly behaves differently from accessing the domain, check DNS and IP-based rules.
- Protect local edits: Keep a copy of your local changes before updating a remote configuration. Downloading the remote configuration again may overwrite manual rules. Updating a node subscription and updating a configuration file are different operations.
If you need subscription details, get them from your provider. This guide assumes you already have a working egress; editing rules does not create new connection resources. For a systematic review of Config, DNS, and On Demand settings, see the Settings Reference. For rule keywords, see the Glossary.
7. Shadowrocket rule priority: common questions
Why does an exact domain rule still connect directly?
First, make sure Home → Global Routing is set to Config. Then check for a DOMAIN-SUFFIX, GEOIP, or other broad match above the exact rule that could catch the connection first. Move the exception above the covering rule, save, and test again with a new connection.
Is the rule broken if a webpage won't load after I set it to REJECT?
If the failed request matches REJECT, that is the expected behavior. Check whether the rejected destination is one you meant to block or a domain required by the page for authentication or API requests. Add an earlier exception only for a false match; don't delete every reject rule.
Why did local network access change after I switched FINAL to PROXY?
That indicates the relevant connections were not caught by an earlier direct rule. Check whether you access the destination by domain or literal IP, whether the destination is IPv4 or IPv6, and whether internal DNS returns the expected address. The three private IPv4 ranges in this guide do not cover IPv6 and are not a complete local network policy.
How do I keep my rules from reverting after an update?
First, check whether you updated a node subscription in Home or a remote configuration file in Config. If it was the latter, back up your local file, compare the new [Rule] section, and merge your custom exceptions again. Don't assume a remote file update preserves manual edits.