This guide uses Shadowrocket on iPhone and iPad as its example. It’s for users who can already connect manually and want to avoid repeating steps after switching networks. First, learn the difference between On Demand and Global Routing; then set up rules for specific Wi-Fi networks and cellular data; finally, check domain evaluation conditions, rule order, and reasons for automatic reconnection. Domain-based On Demand relies on the system’s connection evaluation—it does not start a connection unconditionally whenever a web address is opened.
1. On Demand controls when to connect; Global Routing controls where requests go
On Demand determines when to establish or disconnect a VPN connection—not which route a website uses. In Shadowrocket, open Settings → On Demand to review your On Demand settings. Once connected, requests are handled according to Global Routing in Home and the current Config.
For example, setting a Wi-Fi rule to Disconnect disconnects the VPN when that network matches. By contrast, adding DOMAIN-SUFFIX,example.com,DIRECT routes matching requests directly while connected. These settings operate at different levels: a DIRECT rule in Config cannot replace Disconnect in On Demand.
Proxy, Direct, Config, and Scene in Global Routing are not four types of automatic connection conditions. When troubleshooting, note which option is selected. To check domain routing rules in a configuration file, use Config. Scene behavior depends on its settings, so check it separately; changes in request routing caused by a scene change should not be attributed to On Demand.
2. Test manual connections before enabling On Demand
A working manual connection is essential before testing automatic connections. On Demand cannot fill in a server address, port, or authentication details, and it cannot fix an expired subscription. This guide assumes you already have your own service and configuration. This site does not provide, sell, or recommend nodes or subscriptions.
- In Home, confirm that a usable connection profile is available and check it against the details from your service provider. Subscription updates and On Demand are separate; import or update what you need first.
- Temporarily turn off On Demand in Settings → On Demand, then return to Home and connect manually. If prompted to add a VPN configuration for the first time, review the system prompt and follow the device authorization steps.
- Open a page that normally loads, then visit a destination that should be handled by your existing configuration. Confirm that the results match your expectations with the manual connection.
- If you use Config for routing, check which file is active in Config. Then return to Home and verify Global Routing to make sure it isn’t set to Direct by mistake.
- Note the current Wi-Fi name and connection status, then add just one On Demand rule to test. Change one condition at a time to make differences easier to identify.
These steps cover the system’s On Demand feature on iPhone and iPad; other platforms may not have identical menus. Shadowrocket is also available for Mac (Apple silicon and Intel), Windows, Android, and Linux. See the Download page for platform-specific options.
3. Set rules to disconnect on specific Wi-Fi and connect on cellular
List specific network conditions before broader ones. The example below uses the fictional Wi-Fi name Home-WiFi: Disconnect on this Wi-Fi and Connect on cellular. It illustrates rule matching only; it does not mean the network is necessarily trusted or determine whether you should stay connected.
- Open Wi-Fi settings on your iPhone or iPad and check the current network name. Verify spaces, hyphens, and band suffixes too; don’t substitute the router model for the SSID.
- In Shadowrocket, open Settings → On Demand. In the rule editor, choose the Wi-Fi network condition, enter the SSID to match, and set the action to Disconnect.
- Add a cellular network condition and set its action to Connect. This applies when the device switches to cellular data; it is not a domain rule for a particular webpage.
- If you also need rules for other Wi-Fi networks, add each one separately. Put rules that cover any Wi-Fi after rules for specific SSIDs to avoid a broad rule matching first.
- Save your settings and enable On Demand. First check what happens on the specified Wi-Fi. Then turn off Wi-Fi in system settings, confirm the device has switched to cellular, and check the connection again.
Specific Wi-Fi condition
- Path
- Settings → On Demand
- Network type
- Wi-Fi
- Example SSID
- Home-WiFi
- Action
- Disconnect
- Order
- Place before any Wi-Fi condition
Replace the example name with the SSID your device is actually connected to.
Cellular network condition
- Path
- Settings → On Demand
- Network type
- Cellular
- Action
- Connect
- Prerequisite
- Cellular data is enabled and available on the device
- How to test
- Turn off Wi-Fi, then make a new request
This condition cannot be tested on a device without cellular data.
A matching Wi-Fi name doesn’t guarantee that the network environment is the same. Different hotspots can share an SSID and match the same condition. If Disconnect is set, the app also stops using that VPN configuration to handle requests when the rule matches. SSID rules are useful for connection automation, not as a security mechanism for verifying network identity.
4. Domain-based On Demand uses evaluation rules, not URL triggers
Distinguish between evaluating whether a domain requires a connection and routing traffic by domain after connecting. The system’s EvaluateConnection On Demand action can work with the ConnectIfNeeded domain evaluation. This does not mean that visiting a domain always triggers Connect; a connection is established when a matching domain request meets the DNS resolution or reachability evaluation conditions.
- In Settings → On Demand, check whether the current rule editor offers domain evaluation settings. Standard network rules with only Wi-Fi, cellular, and Connect / Disconnect options cannot be used as domain evaluation rules.
- Enter a domain in a supported domain evaluation field, for example
internal.example.com. Enter a hostname, nothttps://, a port, path, or query parameters. This is a fictional domain used to demonstrate the format. - For evaluation using ConnectIfNeeded, check the DNS or probe conditions against your own network requirements. If fields for a specific DNS server or probe address are available, enter only values you already know and have verified.
- Make sure an earlier Disconnect or unconditional Connect rule for the same network hasn’t matched before the domain evaluation rule. Then test on that network.
- Test with a destination you control that genuinely requires a connection to resolve or access, and record the results before and after connecting. A website that always resolves normally on the public internet won’t prove that domain triggering is configured correctly.
DNS caching and an app’s own DNS resolution method can affect test results. If a result is already cached, reloading a page may not generate a new system DNS request. If an app handles encrypted DNS itself, don’t assume its requests are evaluated by the system. If domain evaluation doesn’t trigger, check these prerequisites before repeatedly changing the server port.
A domain rule doesn’t mean that closing a webpage immediately disconnects the VPN. The system evaluates network and connection conditions, not whether a browser tab is open; background apps may also continue making requests. To disconnect on a specific Wi-Fi network, use the relevant network Disconnect condition rather than treating a closed webpage as a disconnect event.
5. Check On Demand rule order and Config routing order separately
Check the order of both rule sets, but don’t treat them as one list. On Demand evaluates network conditions in rule order, and the first matching action can determine whether a connection is established. After connection, routing rules in Config determine where requests go. Domain evaluation belongs to the first layer; DOMAIN-SUFFIX belongs to the second.
| What to check | Example order | What happens if the order is wrong |
|---|---|---|
| Wi-Fi On Demand rules | Specific SSID Disconnect first, any Wi-Fi Connect after | A broad condition matches first, so the connection stays up on the specified network |
| Domain evaluation rules | Check outer network conditions first, then domain evaluation conditions | Disconnect matches first, so domain evaluation rules never run |
| Config routing rules | Specific domain and IP range rules first, FINAL last | Another rule catches the request first, so it doesn’t use the expected policy |
The following is an example of Config routing syntax, not a setting to paste into On Demand. DOMAIN-SUFFIX matches domain suffixes, IP-CIDR matches IP ranges, GEOIP checks an IP geolocation database, and FINAL handles requests that didn’t match earlier rules. Actual results also depend on DNS results, available destination information, and the current configuration.
DOMAIN-SUFFIX,example.com,PROXY
IP-CIDR,192.168.0.0/16,DIRECT
GEOIP,CN,DIRECT
FINAL,PROXY
To test this routing logic, first make sure Global Routing is set to Config. If it’s set to Direct, a domain not using PROXY doesn’t indicate that On Demand has failed. Likewise, a connected status in Home only confirms the connection state; it doesn’t prove that all requests use the same outbound route.
6. Troubleshoot automatic reconnections, Wi-Fi mismatches, and domain triggers
When troubleshooting On Demand, keep one reproducible set of conditions at a time. Record the network before and after switching, rule order, connection status in Home, Global Routing, and the result of accessing your destination. This makes it easier to identify the problem layer than repeatedly toggling the connection. The issues below are clues, not behavior that occurs on every device.
Why does it reconnect after I disconnect in Home?
First turn off On Demand in Settings → On Demand, then disconnect in Home. If it no longer reconnects, check whether the current network matches a Connect condition or a broader rule. When On Demand is enabled, manually disconnecting doesn’t remove the system’s automatic connection conditions.
Why does it stay connected even though I set my home Wi-Fi to disconnect?
First check the current SSID in system Wi-Fi settings. Make sure you haven’t connected to another network with a different suffix. Then move that SSID’s Disconnect rule ahead of any Wi-Fi Connect rule. Rejoin the network and check again; don’t rely only on a status left over from before you saved the rule.
It didn’t connect after I left Wi-Fi. Is the cellular rule broken?
First confirm the device has usable cellular data and isn’t still without a network connection. Then check that the cellular condition is saved and On Demand is enabled. Temporarily turn off On Demand and try connecting manually. If that also fails, troubleshoot the network, server, and configuration before changing the rule order.
It doesn’t connect when I visit a specific domain. Should I use DOMAIN-SUFFIX?
Don’t use a routing rule as a substitute for domain evaluation. First confirm the relevant EvaluateConnection / ConnectIfNeeded settings are in place. Then check whether an earlier network rule matches first, whether DNS results are cached, and whether the domain already resolves normally without a connection. DOMAIN-SUFFIX only affects routing after connection.
It says connected, but access still doesn’t work as expected. What should I check?
First check Global Routing in Home, then verify the active file and rule order in Config. Also make sure your existing connection works. If the configuration uses DIRECT, a connected status and direct access to the destination can both be expected. Don’t conclude that On Demand failed based only on the result of accessing the destination.
Handle public Wi-Fi sign-in separately. If the device hasn’t completed authentication, a matching Connect condition may still be unable to establish a tunnel. Temporarily turn off On Demand, sign in to the network, and verify that ordinary browsing works before restoring your settings. Don’t permanently remove all On Demand rules just to display the sign-in page.
7. Verify and restore settings in a fixed order
After setting up the rules, test each network condition separately, then restore your everyday settings. Limit your conclusions to the devices and networks you actually tested; one successful switch doesn’t mean every network and app will trigger the same way.
- Specific Wi-Fi: Confirm the SSID matches the rule, check the connection status under the Disconnect condition, and verify that access to your destination behaves as expected after disconnecting.
- Cellular: Turn off Wi-Fi in system settings, wait until cellular data is available, then check whether the Connect condition establishes a connection.
- Other Wi-Fi: Check whether there’s an explicit action for the network. Don’t apply results from a specific SSID test to networks without their own rule.
- Domain evaluation: Confirm that requests use the expected resolution path and record the difference before and after connecting. Don’t use repeated reloads of the same cached page as a substitute for testing.
- Pause automation: Turn off On Demand in Settings → On Demand first, then disconnect in Home. To resume, enable it again and retest on the current network.
Keep only rules you can explain. For each one, be able to answer: which network or domain condition does it match, what action does it take, and why is it in this position? For help checking other settings, see the Settings Manual. If you haven’t completed the basic connection setup, follow the tutorial to connect manually before testing On Demand.
Shadowrocket download and basic connection setup
Get the iPhone / iPad version on the App Store for a one-time payment of $2.99; check the App Store listing for system requirements. The Mac (Apple silicon / Intel), Windows, Android, and Linux versions are free. The Download page lists options for each platform, and the tutorial covers initial setup and connection checks.