For users with an existing provider configuration who want to adjust Shadowrocket’s traffic routing. First, set Global Routing to Config, then order rules with specific exceptions first, broader conditions later, and FINAL last. The examples below use reserved example domains and private IP ranges to explain the syntax, followed by steps for saving, testing, and restoring changes. They illustrate matching behavior and are not complete files to replace an existing configuration.
1. Check Global Routing before reviewing rules
Shadowrocket’s connection status and whether its rules are being applied are separate things. The connection switch in Home starts a connection, Config manages configuration files, and Settings contains app preferences. Being connected does not mean custom rules are currently routing traffic. Before troubleshooting, check Global Routing in Home.
To test these rules, set Global Routing to Config and make sure the file you edited is the one enabled in Config. Proxy applies the global proxy mode, while Direct applies the global direct mode; neither tests each individual routing rule in the configuration. Scene follows the behavior configured for the selected scene, so check its result rather than treating it as equivalent to Config.
- In Home, check the currently selected, available connection and keep your existing provider settings.
- Open Config, confirm which configuration file is enabled, and back up its contents first.
- Return to Home, set Global Routing to Config, then test with a new request.
- Keep the network, selected connection, and destination unchanged during testing. Change one rule at a time.
Settings → On Demand controls whether a connection starts or resumes automatically when its conditions are met; it does not change rule order. If the connection resumes automatically during testing, check this setting. Repeatedly changing On Demand will not fix a domain-matching problem.
2. Rules are checked from top to bottom; matching stops at the first hit
Rules are not automatically sorted by how “specific” they appear. For the request information available to match, Shadowrocket checks rules in configuration order. The first matching rule determines the action, and later rules are not considered for that request. An exact domain placed below a broad suffix rule does not automatically get higher priority.
[Rule]
DOMAIN,login.example.com,DIRECT
DOMAIN-SUFFIX,example.com,PROXY
FINAL,DIRECT
In this example, a request to login.example.com matches the first domain rule and uses DIRECT. A request to docs.example.com matches the second rule and uses PROXY. If the second rule comes first, login.example.com also falls within the example.com suffix, so PROXY is applied first.
- Use
DOMAINfor an exact domain when you want to change routing for a single hostname. DOMAIN-SUFFIXmatches the domain itself and its subdomains, such asexample.comandapi.example.com.- Enter a hostname as the match value. Do not include
https://, a path, or query parameters. DOMAIN-SUFFIX,example.com,PROXYdoes not match every domain whose text containsexample.com.
Real websites usually connect to multiple hostnames. A site’s homepage using DIRECT does not mean its images, login endpoints, or video requests also use DIRECT. Check the specific request that is failing rather than changing rules based only on the main domain in the browser’s address bar.
3. What PROXY, DIRECT, and REJECT do—and their limits
A rule line typically contains a rule type, a match value, and an action, separated by commas. PROXY, DIRECT, and REJECT are actions, not protocols. Connection protocols such as Shadowsocks, VMess, VLESS, Trojan, Hysteria2, and WireGuard operate at a different layer. Changing a rule to PROXY will not fix an incorrect server port or authentication setting.
| Action | What it does | When to use it and limitations |
|---|---|---|
PROXY | Route traffic through the proxy connection. | For destinations that need a proxy. The selected connection must be available, and access must be allowed by your provider. |
DIRECT | Access the destination directly over the current network. | For services confirmed to be reachable directly or for local network destinations. Local network conditions and system permissions still apply. |
REJECT | Block the matching connection. | For destinations you explicitly want to block. It does not switch to another route automatically if a connection fails. |
For example, use an exact IP rule for a local network device. For a sample hostname you have confirmed should be blocked, use an exact domain rejection rule. Test with a narrow match first, then consider expanding it to the entire domain suffix. This helps avoid blocking login endpoints or static resources on the same domain unintentionally.
[Rule]
IP-CIDR,192.168.1.20/32,DIRECT,no-resolve
DOMAIN,blocked.example.net,REJECT
DOMAIN-SUFFIX,example.com,PROXY
FINAL,DIRECT
192.168.1.20/32 represents one IPv4 address. If a device serves requests on port 8080 at that address, you still need to use the correct port. The IP-CIDR rule itself does not specify a port or make a closed port reachable. For a custom policy group, also check the policy name and the selection within the group; the text at the end of a rule alone does not determine the final route.
4. Ordering DOMAIN-SUFFIX, IP-CIDR, and GEOIP rules
Domain and IP rules match different kinds of input. DOMAIN-SUFFIX relies on available domain information; IP-CIDR checks whether an address falls within a specified range; GEOIP classifies an IP using a geolocation database. A domain’s content language, the company’s location, and the region associated with its resolved IP are not the same thing. GEOIP is not a substitute for a specific domain-based rule.
Domain matching examples
- Exact hostname
DOMAIN,login.example.com,DIRECT- Domain suffix
DOMAIN-SUFFIX,example.com,PROXY- Order
- Put exact exceptions before suffix-wide rules.
Do not include URL paths in the domain field. Example domains do not represent working services.
IP matching examples
- Private IP range
IP-CIDR,192.168.1.0/24,DIRECT,no-resolve- Geolocation
GEOIP,CN,DIRECT- Final fallback
FINAL,PROXY
IP rules require a destination address. Geolocation results depend on the database in use.
192.168.1.0/24 represents an IPv4 subnet and covers a wider range than 192.168.1.20/32. It applies only when that subnet is actually used on the local network; home and office networks do not all share the same address range. If a local network device is unreachable, also check its address, network isolation, and system permissions for local network access.
no-resolve means not to initiate a DNS lookup specifically for this IP rule. The rule can still match when the destination is an IP address or an address is already available. It does not “turn off all DNS,” nor does it guarantee that every request made with a domain name will match the IP range rule. If routing depends on IP classification, check both the request’s destination details and DNS behavior.
- Put domain exceptions that need to override general classification before GEOIP rules.
- Put specific local network address rules before broader rules that could match them.
- When using IP-CIDR, keep the correct prefix length. Do not accidentally expand a single address to an entire subnet.
- A domain can resolve to multiple addresses. When testing IPv4 and IPv6, do not assume both use the same address rules.
5. Put FINAL last to handle requests with no earlier match
FINAL is a fallback rule and does not require a domain or subnet match value. Common forms are FINAL,PROXY and FINAL,DIRECT. A request reaches FINAL only when none of the preceding rules match. If FINAL appears in the middle, ordinary rules below it will no longer get a chance to match.
[Rule]
DOMAIN,login.example.com,DIRECT
DOMAIN,blocked.example.net,REJECT
DOMAIN-SUFFIX,example.com,PROXY
IP-CIDR,192.168.1.0/24,DIRECT,no-resolve
GEOIP,CN,DIRECT
FINAL,PROXY
This snippet processes exact exceptions, blocked destinations, specified domains, local network addresses, and geolocation rules in order, then routes remaining requests through PROXY. It demonstrates rule order only; it does not include complete connection, DNS, or policy group settings. Do not use it to replace other sections of an existing configuration.
| Fallback action | When no earlier rule matches | Check before changing |
|---|---|---|
FINAL,PROXY | Route through the proxy connection. | Whether unknown destinations should also use the proxy, and whether the current connection is available. |
FINAL,DIRECT | Connect directly over the current network. | Whether domains that need a proxy are already covered by earlier rules. |
FINAL,REJECT | Reject all remaining requests. | Whether you explicitly intend to use an allowlist and have covered all required dependencies. |
FINAL is not failover. After FINAL,PROXY matches, do not expect it to switch to DIRECT automatically if the selected proxy is unavailable. Likewise, if a preceding DIRECT rule fails to connect, rule evaluation does not continue down to FINAL. Troubleshoot rule matching separately from connection failures.
6. Save changes, test individual requests, and restore if needed
Save a copy of the original file before editing. After making changes, confirm the file was saved and is enabled. Test with a new connection: existing long-lived connections may continue using the old route, and browser cache may make a page appear unchanged. If reconnecting, first check for active downloads or calls to avoid interrupting them.
- Start by adding just one exact domain rule, such as
DOMAIN,login.example.com,DIRECT, above any existing broad rules. - Confirm Home → Global Routing is set to Config, then make a new request to that hostname.
- Check the app’s connection records or logs for the destination hostname, matched rule, and action. Do not use latency test results as proof of how traffic was routed.
- If the expected rule matched but the connection failed, check DNS, the destination port, the selected connection, and your provider settings. Do not keep moving rules around without evidence.
- If the change affects other services, restore your backup, narrow the rule’s scope, and test again.
Why is traffic still using PROXY when I added a DIRECT rule?
First check whether Home → Global Routing is set to Config. Then look for a matching DOMAIN-SUFFIX, rule set, or other broad rule above DIRECT. Move the exact exception above the rule that is taking precedence, save, and test with a new request. Also confirm that the hostname in the request log is the one you changed.
Why can’t a specific website connect directly after I changed FINAL to DIRECT?
FINAL handles only requests that did not match earlier rules. Check whether an earlier PROXY or REJECT rule handled the request. To override one, add an exact rule for the destination domain above it rather than changing the fallback at the end.
Why did my custom rules disappear after refreshing a subscription?
First check whether you refreshed a connection subscription in Home or a remote configuration in Config. Refreshing the former mainly updates the connection list; it does not rewrite rules. Refreshing the latter may replace file contents. To keep your changes, back up the file and save a local copy first, then confirm which file is enabled. Avoid repeatedly editing remote content that may be replaced.
Do I need to add every domain a website uses?
Check failed request records to see what the site depends on. Login endpoints, static assets, and media may use different domains; add rules for the actual destinations as needed. Do not broaden a rule to cover a large suffix just because one request failed, and do not enter a full URL with a path in DOMAIN.
Rules determine routing; they do not provide a connection
This guide assumes you already have a provider and subscription. This site does not provide, sell, or recommend nodes or subscriptions. A one-time app purchase is not a connection plan. Even when a rule matches correctly, you still need to check your local network, provider connection, and destination service separately.