Check Shadowrocket custom rules in Config mode under Global Routing: put specific exceptions first, broader rules later, and FINAL last. For users with a working configuration who want to adjust traffic routing, this guide covers rule syntax, policy differences, ordering, and testing. Examples use reserved example domains and include no connection details for any service.
1. Rule order: first match wins—not the most specific
Shadowrocket checks rules in the order they appear in the configuration. When a connection matches a rule, Shadowrocket applies that rule’s policy and stops; it does not continue looking for a “more specific” match. Domain rules do not automatically take precedence over IP rules, and exact-domain rules are not automatically placed ahead of suffix rules. To handle an exception, put it earlier in the list.
For example, to send login.example.com DIRECT while routing example.com and its other subdomains through PROXY, order the rules as shown below. If you swap the first two lines, the login domain will match DOMAIN-SUFFIX first, and the later DOMAIN rule cannot change the decision already made.
[Rule]
DOMAIN,login.example.com,DIRECT
DOMAIN-SUFFIX,example.com,PROXY
FINAL,DIRECT
Key takeaway: move exceptions before adding rules
If an exact rule has no effect, first check whether an earlier rule already covers the same target. Move any necessary exception above that rule, then test with a new connection instead of repeatedly adding duplicate lines.
2. PROXY, DIRECT, and REJECT: how connections are handled
The first part of a rule specifies what to match; its final field specifies how to handle the connection. PROXY sends it through the proxy route; the actual exit depends on the currently selected server or the policy setup in the configuration. DIRECT connects to the destination without using a proxy exit. REJECT blocks the matching connection. These are not protocol names like Shadowsocks, VMess, VLESS, or Trojan, nor are they ratings of connection quality.
| Policy | Rule example | What to check |
|---|---|---|
PROXY | DOMAIN,api.example.com,PROXY | A working proxy configuration is in place, and the selected server is available. |
DIRECT | DOMAIN,printer.example.com,DIRECT | The current network can reach the destination directly, and DNS resolves it correctly. |
REJECT | DOMAIN,blocked.example.com,REJECT | The domain really should be blocked, rather than being needed for sign-in or page resources to load. |
DIRECT does not guarantee a successful connection. The destination may deny access, the local network may be unavailable, or DNS may return an incorrect address. Similarly, a PROXY match only means the rule selected the proxy route; it does not guarantee that the remote service is reachable. When troubleshooting, check “Was the intended route selected?” and “Does that route work?” separately.
3. Global Routing: test custom rules in Config mode
First check the current mode under Home → Global Routing, then assess whether the rule is working. Config routes traffic according to the rules in the active configuration. Proxy and Direct are useful for comparing routes, but they do not prove that a particular custom rule matched. Scene involves selecting a scene; avoid changing scenes during initial troubleshooting, or your test conditions may change.
Config
RecommendedUses the rules in the currently active configuration. Rules can select PROXY, DIRECT, or REJECT; FINAL handles connections that do not match any rule.
Use it to edit and test custom rules while preserving different routing for different destinations.
Proxy
Sends traffic through the proxy route. Temporarily switching to this mode can show whether the same destination is reachable through the proxy, but it does not test which rule matched in the current rule list.
Use it to compare with Config and check whether the proxy route itself works.
Direct
Sends traffic through a direct connection. If the result differs from Config, check the rules and logs rather than immediately changing the protocol.
Use it to temporarily check whether the current network can reach the destination directly.
After comparing routes, switch back to Config. Settings → On Demand manages when connections are made on demand; it does not reorder rules or make rules placed after FINAL reachable. Keep the network and connection state stable during testing. Avoid changing automatic connection behavior, switching networks, and editing rules at the same time.
4. Common rule syntax: domains, IP ranges, and FINAL
Common rules use commas between fields, not the full-width Chinese comma. For domain matches, enter only the domain—no https://, port, or URL path. For example, when visiting https://api.example.com:443/v1, the DOMAIN target is api.example.com, not the entire URL. Port 443 belongs to this example connection, not to the domain field.
| Keyword | Valid example | What it matches and what to know |
|---|---|---|
DOMAIN | DOMAIN,api.example.com,PROXY | Matches the exact domain; subdomains are not included automatically. |
DOMAIN-SUFFIX | DOMAIN-SUFFIX,example.com,PROXY | Matches example.com and its subdomains. Do not write *.example.com. |
IP-CIDR | IP-CIDR,192.168.0.0/16,DIRECT,no-resolve | Matches an IPv4 range; /16 means the first 16 bits are the network prefix. |
GEOIP | GEOIP,CN,DIRECT | Uses an IP geolocation database; it does not determine location from the domain suffix. |
FINAL | FINAL,PROXY | Has no target field and handles connections not matched by any preceding rule. |
no-resolve after IP-CIDR means the rule will not actively trigger a domain lookup just to test the match. It does not mean that every domain is resolved first and then checked against the IP range. When testing devices on a local network, check access by IP address and by device hostname separately, and note whether DNS returns a public or private address.
GEOIP relies on IP geolocation data. Its result is not based on a website’s language, domain suffix, or operator’s location. If a service must always use a specific route, an explicit domain rule placed before GEOIP is easier to verify than an indirect decision based on IP location.
- Check characters: Make sure keywords, commas, and policy fields are complete, and watch for full-width characters introduced when copying.
- Check scope:
DOMAIN-SUFFIX,example.comdoes not matchnotexample.comand does not refer to a URL subdirectory. - Check addresses:
192.168.0.0/16is an example of a private IP range; it does not mean your local network uses that range. - Check the fallback: Keep one valid FINAL rule and place it at the end of the active rule list.
5. Recommended order: specific exceptions first, FINAL last
Here is a rule example to illustrate the order: allow a specific login domain to connect directly, reject a specific domain, then handle the domain suffix as a whole; next, handle the private IP range and GEOIP, and finally send unmatched traffic to FINAL. This demonstrates ordering, not a one-size-fits-all configuration. Remove or adjust rules to suit your actual destinations.
[Rule]
DOMAIN,login.example.com,DIRECT
DOMAIN,blocked.example.com,REJECT
DOMAIN-SUFFIX,example.com,PROXY
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
This order puts “specific exceptions first,” but it does not mean domain rules must always come before IP ranges. If all local network destinations must connect directly, also check whether an earlier domain rule could route a destination resolved to a local IP through PROXY, and adjust for DNS behavior. Order rules to match your intent; do not treat one example as a fixed priority scheme.
- Visit login.example.com: The first DOMAIN rule matches and selects DIRECT; later suffix rules are not checked.
- Visit blocked.example.com: The second rule matches and selects REJECT. Moving it below the suffix rule would change the result.
- Visit api.example.com: The first two rules do not match. DOMAIN-SUFFIX matches next and selects PROXY.
- Connect directly to 192.168.1.1: If none of the earlier domain rules match, the corresponding private IP range rule matches and connects directly.
- Visit another destination: GEOIP is checked next; if it still does not match, the connection reaches FINAL.
FINAL,PROXY and FINAL,DIRECT are both valid fallback choices. The difference is which route unknown destinations take by default. FINAL is not a retry mechanism for failed connections: if an earlier rule selects PROXY and the proxy connection fails, the connection does not skip that rule and fall through to FINAL. To change the route for a failing destination, edit the relevant rule or fix the selected connection.
6. Edit and test: change one condition at a time
The steps below refer to the iPhone / iPad interface. Rules belong to the configuration file active in Config; changes to the server list in Home do not mean the rule file has also been updated. Back up the original configuration before editing, and make sure you know whether you are changing a local file or one that may be overwritten by a remote update.
-
Check the mode
Go to Home → Global Routing and select Config. Note the currently selected server, and do not change the exit route during testing.
-
Check the file
Open Config and confirm which configuration file is active. Preserve the original contents before editing. Changes to a different, inactive file will not affect traffic routing for the current connection.
-
Reorder the rules
Find [Rule] in the configuration and move specific exceptions above any rules that cover them. Confirm that FINAL is last. If you are copying rule lines only, do not insert another section header into an existing [Rule] section.
-
Save and reconnect
Save the changes and confirm that the edited configuration is active. Reconnect if needed. Close the old test page or end the existing connection, then make a new request to avoid reusing a connection established before the edit.
-
Check the result
Look for the destination domain, destination IP, and applied policy in the connection records or logs. Record the test destination, match result, and observed behavior before making further changes.
Build a minimal test set with three destinations: one expected to use DIRECT, one expected to use PROXY, and one without a specific rule that should reach FINAL. If you intentionally use REJECT, add one clearly identified blocking test. Do not judge rule correctness solely by whether a webpage opens: both DIRECT and PROXY can work, and pages may reuse cached content.
Key takeaway: use match records to tell two types of failure apart
If the recorded policy differs from what you expected, first check the mode, active file, and rule order. If the policy is correct but the connection fails, check DNS, the selected server, and the current network. Do not keep stacking duplicate rules.
7. Rules not working: troubleshoot by symptom
Rule problems often come from changing test conditions, not from a lack of rules. Start with a destination you can test repeatedly, then work through the checks below. For broader network troubleshooting, see Troubleshooting.
Changed a rule, but nothing changed?
First check that Home → Global Routing is set to Config, then confirm that the active file under Config is the one you edited. After saving, make a new connection. Persistent connections, page caches, and existing sessions can all make old results appear to continue.
Why didn’t an exact DOMAIN rule override the suffix rule?
Check whether it appears below DOMAIN-SUFFIX or another rule that already matched. Rules run in order; they are not resorted by specificity. Move the exception above the covering rule, then verify the domain in the actual request in case the page redirected to a different domain.
Can I add an exception after FINAL?
Do not order rules that way. FINAL handles every unmatched connection that reaches it, so rules after it never get a chance to match. Insert the new rule above FINAL, then check whether an earlier, broader rule still covers it.
Why do connections to one website use different policies?
A page may make separate requests to a sign-in domain, a static asset domain, and an API domain. Each connection is matched independently. Check the domain of the specific failed request instead of assuming that every resource uses the same policy as the main domain in the address bar.
My custom rules disappeared after an update. What should I check?
Distinguish between updating a server subscription in Home and updating a remote configuration file in Config. A remote configuration update may replace file contents. Compare the file with your backup to identify what changed, then decide how to preserve local edits. Do not assume every update works the same way.
Finally, confirm three things: Config is selected, the correct file is active, and exceptions appear before broader rules. Once all three are confirmed, check the final policy using a new connection. Rules select how traffic is handled; they cannot verify the availability of services you already use or automatically fix invalid connection settings.
Shadowrocket Download and Initial Setup
The iPhone / iPad app costs $2.99 as a one-time App Store purchase. The Mac (Apple silicon / Intel), Windows, Android, and Linux versions are free. Check the App Store listing for the iPhone / iPad system requirements. Buying the app does not include a network service. For initial setup, use your existing service details; this site does not provide, sell, or recommend nodes or subscriptions.