The Complete Clash Configuration Workflow: A Practical Guide from Subscription Links to Rule Strategies
1. Obtaining and Importing Subscription Links
Clash's core functionality relies on proxy server node information, which is typically obtained through subscription links.
Obtaining a Subscription Link:
- Purchase service from a reliable proxy service provider, who will provide a dedicated subscription link (usually starting with
https://). - Some open-source projects or communities offer free public subscriptions, but security and stability are not guaranteed.
Importing the Subscription Link:
- In the Clash Client: Open Clash (e.g., Clash for Windows, ClashX, Stash), and navigate to the "Profiles" or "Subscriptions" page.
- Add Subscription: Click the "Add" or "Download" button and paste the complete subscription link into the input field.
- Update Configuration: After confirmation, Clash will automatically download and parse the subscription content, generating a configuration file (e.g.,
config.yaml). - Activate Configuration: Select the newly downloaded configuration file from the list and set it as the active profile.
Security Note: The subscription link is your credential for accessing the service; do not share it. Update your subscription regularly to get the latest node list.
2. Understanding Proxy Modes and Policy Groups
Clash uses "Proxy Modes" and "Policy Groups" to precisely control traffic routing.
Proxy Mode:
- Rule Mode: The most common mode. Decides traffic routing (direct, proxy, or reject) based on predefined rules (e.g., domain, IP, GeoIP).
- Global Mode: All traffic goes through a specified proxy or policy group. Suitable for scenarios requiring a global proxy.
- Direct Mode: All traffic bypasses the proxy.
Policy Groups: Policy groups are collections of proxy nodes. You can assign different groups to different types of traffic. Common policy group types include:
- Select: Manually choose one node from the group to use.
- URL-Test: Automatically tests the latency and availability of nodes in the group and selects the fastest one.
- Fallback: Tests nodes in order and uses the first available one.
- Load-Balance: Distributes traffic evenly among nodes in the group.
Configuration Example (YAML):
proxy-groups:
- name: "🚀 Auto-Select"
type: url-test
proxies:
- "HK-Node-01"
- "JP-Node-02"
- "US-Node-03"
url: 'http://www.gstatic.com/generate_204'
interval: 300
- name: "🎬 Streaming"
type: select
proxies:
- "🚀 Auto-Select"
- "HK-Node-01"
- "DIRECT"
3. Detailed Rule Configuration
Rules are the core of Clash's operation in "Rule Mode". Rules are matched from top to bottom; the first match is executed.
Rule Format: TYPE,VALUE,POLICY
- Type (TYPE): e.g.,
DOMAIN-SUFFIX,DOMAIN,IP-CIDR,GEOIP,MATCH(catch-all rule). - Value (VALUE): e.g.,
google.com,192.168.1.0/24,CN. - Policy (POLICY): Specifies the traffic destination. Can be a specific proxy node, a policy group name,
DIRECT, orREJECT.
Custom Rule Practices:
- Route Domestic Traffic: Set websites and IPs in mainland China to
DIRECTfor faster access. - Proxy Specific Services: Direct specific streaming, social media, or work websites to dedicated high-speed policy groups.
- Block Ads: Use the
REJECTpolicy to block advertising domains.
Rule Configuration Example:
rules:
# Direct traffic for domestic domains and IPs
- DOMAIN-SUFFIX,cn,DIRECT
- GEOIP,CN,DIRECT
# Proxy streaming services
- DOMAIN-SUFFIX,netflix.com,🎬 Streaming
- DOMAIN-SUFFIX,disneyplus.com,🎬 Streaming
# Proxy common overseas services
- DOMAIN-SUFFIX,google.com,🚀 Auto-Select
- DOMAIN-SUFFIX,twitter.com,🚀 Auto-Select
# Block ads
- DOMAIN-SUFFIX,doubleclick.net,REJECT
# Catch-all rule: Proxy all other unmatched traffic
- MATCH,🚀 Auto-Select
It's recommended to use mature rule sets (like the Clash-rules project) as a base and fine-tune them according to personal needs.
4. Common Troubleshooting
If you encounter issues, follow these steps to troubleshoot:
-
Cannot Connect / No Internet:
- Check if the system proxy or TUN mode is correctly enabled.
- Check if the proxy nodes in the configuration are valid (try manually testing latency on the "Proxies" page).
- Check if the rules are too strict, causing essential traffic to be
REJECTed or directed to a failed node.
-
Some Websites Are Inaccessible:
- Check if the rule for that website is correctly configured. Use Clash's "Connections" or "Logs" page to see the matching details for specific traffic.
- It might be a DNS issue. Try enabling the
dnssection in the configuration or usefallbackandnameserverto configure reliable DNS servers.
-
Slow Speed:
- Run a speed test for
url-testtype policy groups and switch to a faster node. - Check if domestic traffic that should be direct is mistakenly routed through the proxy due to improper rule configuration.
- Run a speed test for
-
Configuration Update Failed:
- Check if the subscription link is valid and has not expired.
- Check your network connection. Try manually accessing the subscription link in a browser to see if you can download the configuration file.
-
Client Fails to Start or Crashes:
- Check the configuration file syntax (YAML format) for correctness and proper indentation. Using an online YAML validator is recommended.
- It might be a version incompatibility between the client and the configuration syntax. Try updating the client or using a more generic configuration format.
Related reading
- Tuic Protocol Practical Guide: Building High-Performance, Low-Latency Modern Network Proxy Services
- Deep Dive into the Clash Rule Engine: Technical Implementation from Policy Matching to Traffic Distribution
- V2Ray Performance Tuning Guide: Best Practices for Configuration Parameters, Transport Protocols, and Network Environments