Shadowrocket Custom Rules: Match Order, FINAL Fallback, and PROXY/DIRECT/REJECT

Learn Shadowrocket custom rule syntax, first-match priority, where to place FINAL, and how PROXY, DIRECT, and REJECT handle requests.

At a Glance

Shadowrocket checks custom rules from top to bottom and applies the policy on the first match—it does not keep searching for a “more specific” rule. This guide is for users who have already configured a connection and need domain exceptions or LAN access. First, set Global Routing to Config, put exceptions before broader rules, and leave FINAL at the end. The syntax examples explain rule behavior across platforms; for device-specific steps, refer to the current Home, Config, and Settings screens.

Check That Rules Are Active First

A working Shadowrocket connection and active rules are two separate things. The connection selected in Home determines which proxy outbound is available; the enabled configuration in Config supplies the rules; and Global Routing determines whether requests are routed according to that configuration. If a rule has no effect, check all three before adding more rules.

This guide assumes Global Routing is set to Config. Proxy applies proxy routing globally, while Direct applies direct routing globally; neither setting can be used to test per-rule routing in a configuration. If you use Scene, check which settings the active scene applies—your test conditions may change when the network changes. Global Routing’s Proxy setting and PROXY in a rule are at different levels: the former is a global mode, while the latter is the policy for an individual rule.

  1. In Home, confirm that the current connection is working. Rules using PROXY still need an available proxy outbound.
  2. Open Config and make sure you have selected the configuration you intend to edit, not a similarly named file.
  3. Set Global Routing to Config before adding and testing rules.
  4. Keep the network environment unchanged while testing. If Settings → On Demand is enabled, watch for automatic connection behavior, but don’t treat it as a rule-priority switch.

The following sections cover rule evaluation in a configuration, not protocol settings. Troubleshoot connection settings for Shadowsocks, VMess, VLESS, Trojan, Hysteria2, WireGuard, and other outbound protocols separately from routing conditions such as DOMAIN-SUFFIX.

Basic Rule Syntax

Rules in a configuration file go in the [Rule] section. A typical rule has three parts—rule type, match value, and policy—separated by English commas. FINAL needs no match value, so it has only a type and a policy. Keep keywords unchanged, use English commas, and enter domains without URL paths.

[Rule]
DOMAIN,login.example.com,DIRECT
DOMAIN-SUFFIX,example.com,PROXY
IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
GEOIP,CN,DIRECT
FINAL,PROXY

example.com is a placeholder domain for illustration, not a service endpoint. Don’t use its results to judge connection quality. If the file already has a [Rule] section, edit the relevant entries there; don’t repeatedly add section headers or paste rules into [General].

Domain condition

DOMAIN
login.example.com,DIRECT
DOMAIN-SUFFIX
example.com,PROXY
Match value
Enter a domain without https://, a port, or a path

DOMAIN matches an exact domain; DOMAIN-SUFFIX matches the specified domain and its subdomains.

Address and fallback

IP-CIDR
192.168.0.0/16,DIRECT,no-resolve
GEOIP
CN,DIRECT
FINAL
PROXY

IP conditions match destination addresses; FINAL handles requests not matched by earlier rules.

no-resolve is an optional parameter for IP-based rules that prevents a DNS lookup solely to evaluate that rule. It does not “disable all DNS,” nor does it guarantee a match for a request that has a domain but no destination IP yet. Domain and IP conditions rely on different information, so distinguish between them when testing.

Position Determines Priority

The rule list doesn’t score domains, address ranges, and geographic locations before choosing the most specific condition. It checks rules from top to bottom, and the first matching rule determines the policy. If you put an exact-domain rule below a broad suffix rule, the exact rule may never run.

New request arrives Read the first rule Check conditions in order Stop at the first match Apply the matching policy

Using the list in the previous section as an example, a request to login.example.com matches DOMAIN first and uses DIRECT. A request to static.example.com skips the first rule, then matches DOMAIN-SUFFIX and uses PROXY. If you swap the two lines, login.example.com also matches the example.com suffix and will be routed through PROXY before the later DOMAIN rule gets a chance to apply DIRECT.

Request destinationFirst matching rulePolicy appliedWhy it matches
login.example.comDOMAINDIRECTExact exception appears before the suffix rule
static.example.comDOMAIN-SUFFIXPROXYSubdomain of example.com
192.168.1.20IP-CIDRDIRECTDestination address is within 192.168.0.0/16
Other destinationsGEOIP or FINALDetermined by the first matchCheck the address first; if nothing matches, continue to the fallback

Takeaway: Move exceptions before adding rules

If an exact rule is present but the wrong policy still applies, check whether a broader condition above it covers the same destination. Move the exception above that rule, then test with a new connection. Don’t append another copy of the same rule at the bottom of the list.

Put FINAL at the End

FINAL doesn’t check a domain or address range; it catches any remaining request that reaches it. That’s why it must come after all the rules you want evaluated. A domain exception below FINAL may be syntactically valid, but it will never be reached.

[Rule]
DOMAIN,blocked.example.com,REJECT
DOMAIN,login.example.com,DIRECT
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
FINAL,PROXY

This example orders rules as “specific rejection, domain exception, general domain rule, private address range, final policy.” It isn’t a one-size-fits-all configuration. If an example.com subdomain resolves to a private address, it may still match a domain rule above the private-range rule. If private addresses should take priority and connect directly, account for DNS and destination-address visibility when adjusting the order.

1 rule
The first match determines the result for a request
3 policies
This guide uses PROXY / DIRECT / REJECT
End
FINAL comes after all conditions to be checked

FINAL,PROXY sends requests that matched no earlier condition through the proxy; FINAL,DIRECT connects the rest directly. Neither is universally better—choose based on your default routing needs. To change the default policy, replace the existing FINAL rule rather than keeping multiple conflicting FINAL rules.

How the Three Policies Work

The rule type answers “which requests match?”; the policy answers “what happens when they do?” Changing the policy does not change what the rule matches. For example, changing PROXY to REJECT on a DOMAIN-SUFFIX rule affects every destination covered by that suffix, not just one resource on a webpage.

PolicyActionWhat to check
PROXYSends the request through the proxy outbound configured for useConfirm the outbound works; a rule match alone isn’t enough
DIRECTConnects directly to the destination over the local networkConfirm the current network can reach the destination and its address
REJECTRejects matching requestsThe request failing is usually expected; it doesn’t mean proxy latency has increased

DIRECT doesn’t turn off Shadowrocket’s connection switch, nor does it switch Global Routing to Direct. With the connection still on, different requests can match DIRECT, PROXY, or REJECT. REJECT also doesn’t hide page elements: if a page’s scripts, login API, or image domains are rejected, parts of the page may fail to load.

Save and Test in Order

Keep a copy of the original configuration before editing, and test on a duplicate if possible. Remote configuration updates may overwrite local changes. Updating a service provider’s connection subscription is a separate operation from updating rule configuration. Get subscription links from your service provider; don’t re-import all connections just to adjust one domain rule.

  1. Record the test conditions. Note the destination domain, current network, Global Routing mode, and active configuration. Avoid changing multiple variables at once.
  2. Edit the active configuration. Find the current configuration in Config and use its edit option to check [Rule]. Put each exception above the rule that would otherwise match it.
  3. Check the syntax. Verify English commas, rule keywords, domains, and address ranges. FINAL takes a policy only; don’t add an empty match field.
  4. Save and confirm it’s enabled. After saving, check which file is selected in Config. If the existing connection persists, disconnect and reconnect to rule out effects from the previous session.
  5. Make a new request. Close the existing connection to the destination, then visit it again. Check the destination, matched rule, and outbound policy in the connection records or logs available on your platform.
  6. Change one condition and retest. If the result is wrong, adjust rule order first, then check DNS and the outbound. Avoid changing the protocol, network, and entire configuration at the same time.

Test using new connections. Browser connection reuse, cached pages, and persistent app connections can prevent saved rules from showing up immediately. A page may also contact several domains: a direct connection for the main document doesn’t mean its images, APIs, and video use the same policy.

Common Rule Questions

I added DIRECT. Why is the request still using PROXY?

First, check in Home that Global Routing is set to Config, then confirm the active file in Config. Next, look for a DOMAIN-SUFFIX, GEOIP, or FINAL rule above DIRECT that matches first. Move any necessary exact exception above it, save, and retest using a new connection.

Should I add an asterisk to DOMAIN-SUFFIX?

To match example.com and its subdomains, use DOMAIN-SUFFIX,example.com,PROXY. Don’t add *.example.com or a URL path. To match only login.example.com, use DOMAIN and place it above the broader suffix rule.

I added a private IP range rule. Why won’t my LAN domain load?

First, distinguish between accessing 192.168.1.20 directly and accessing a domain that resolves to that address. Check that LAN DNS can resolve the domain, and whether a domain rule above the IP rule is matching first. An IP-CIDR rule with no-resolve won’t trigger DNS just to check for a match. If needed, add a DOMAIN exception for the known LAN domain above the broader rules.

Why did my custom rules disappear after updating the configuration?

Check whether the update affected a remote rule configuration or a connection subscription in Home. If a remote configuration overwrote the local file, restore your saved copy and check the added rules. Don’t assume manual changes are automatically merged with the remote source. Before relying on a configuration long-term, make sure you understand how it’s saved and updated.

For more match conditions and configuration syntax, see the Rule Reference. If you’re unsure what Config, Global Routing, or DNS means, check the Glossary first. Verify how a small set of rules matches before expanding the list; this makes conflicts and ordering issues easier to identify.

Download Shadowrocket