Why Advanced Configuration
While ClashX works out of the box, advanced configuration enables finer control, higher performance, and smarter automation. This article shares practical advanced tips to help you become a ClashX configuration expert.
These tips are suitable for users already familiar with ClashX basics and can significantly improve daily usage experience.
Advanced policy group configuration, DNS split optimization, custom rule writing, configuration automation scripts, performance tuning techniques
Policy Group Optimization
Understanding Policy Group Types
ClashX supports multiple policy group types, each suitable for different scenarios:
| Type | Description | Best Use Case |
|---|---|---|
| select | Manually select nodes | Services requiring precise control |
| url-test | Auto-select fastest node | Daily browsing, streaming |
| fallback | Failover | High availability scenarios |
| load-balance | Load balancing | High-traffic downloads |
Creating Smart Policy Groups
By combining different policy types, you can build smarter proxy strategies. Here's an example configuration:
Policy Group Configuration Example
proxy-groups:
# Main selector
- name: "🚀 Proxy Select"
type: select
proxies:
- 🇭🇰 Hong Kong Node
- 🇺🇸 US Node
- 🇯🇵 Japan Node
- DIRECT
# Auto SelectHong KongFastest node
- name: "🇭🇰 Hong Kong Node"
type: url-test
url: 'http://www.gstatic.com/generate_204'
interval: 300
use:
- HK-Servers
# Streaming (Failover)
- name: "🎬 Streaming"
type: fallback
url: 'http://www.gstatic.com/generate_204'
interval: 300
proxies:
- 🇭🇰 Hong Kong Node
- 🇺🇸 US Node
Policy Group Nesting Tips
Policy groups can be nested to create hierarchical structures:
- First Layer: Group by region (Hong Kong, US, Japan)
- Second Layer: Group by purpose (streaming, gaming, downloads)
- Third Layer: Master controller (manually choose which policy)
Use emoji icons to name policy groups for quick identification in ClashX menu, improving efficiency.
Advanced DNS Configuration
DNS Pollution Issues
DNS pollution is a common issue affecting network access. Proper DNS configuration can prevent resolution errors and improve access speed.
Optimizing DNS Configuration
Recommended: use split DNS configuration - domestic DNS for domestic domains, trusted DNS for foreign domains:
DNS Split Configuration
dns:
enable: true
ipv6: false
enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/16
nameserver:
- 119.29.29.29
- 223.5.5.5
fallback:
- tls://1.1.1.1:853
- tls://8.8.8.8:853
fallback-filter:
geoip: true
geoip-code: CN
ipcidr:
- 240.0.0.0/4
fake-ip vs redir-host
Choose the appropriate DNS enhancement mode:
fake-ip mode may cause connection issues with certain apps (like Spotify, Steam). If you encounter such issues, switch to redir-host mode.
DoH / DoT Encrypted DNS
Use encrypted DNS for enhanced privacy:
- DoH (DNS over HTTPS): Encrypt DNS queries via HTTPS
- DoT (DNS over TLS): Encrypt DNS queries via TLS
- Recommended services: Cloudflare (1.1.1.1), Google (8.8.8.8)
Rule Customization
Rule Priority
Understanding rule matching order is crucial. ClashX matches rules from top to bottom, applying the first matching rule.
1. DOMAIN (exact domain)
2. DOMAIN-SUFFIX (domain suffix)
3. DOMAIN-KEYWORD (domain keyword)
4. IP-CIDR (IP address range)
5. GEOIP (geographic location)
6. MATCH (default match)
Common Rule Examples
Here are some practical custom rules:
Rule Configuration Examples
rules:
# Ad blocking
- DOMAIN-SUFFIX,ads.google.com,REJECT
- DOMAIN-KEYWORD,analytics,REJECT
# Force Direct
- DOMAIN-SUFFIX,apple.com,DIRECT
- DOMAIN-SUFFIX,icloud.com,DIRECT
# StreamingRouting
- DOMAIN-SUFFIX,netflix.com,🎬 Streaming
- DOMAIN-SUFFIX,youtube.com,🎬 Streaming
# CN websitesDirect
- GEOIP,CN,DIRECT
# Other traffic via proxy
- MATCH,🚀 Proxy Select
Rule Set References
Using rule sets simplifies configuration and keeps it updated:
Rule Set Configuration
rule-providers:
reject:
type: http
behavior: domain
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/reject.txt"
path: ./ruleset/reject.yaml
interval: 86400
proxy:
type: http
behavior: domain
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/proxy.txt"
path: ./ruleset/proxy.yaml
interval: 86400
rules:
- RULE-SET,reject,REJECT
- RULE-SET,proxy,🚀 Proxy Select
Automation Configuration
Subscription Conversion Services
Use subscription conversion services to auto-optimize configurations:
- Auto-add rule sets
- Auto-group nodes
- Auto-update configuration
- Custom configuration templates
Subconverter, ACL4SSR and other services provide free subscription conversion with various customization options.
Configuration Preprocessor
Use ClashX's configuration preprocessing for advanced customization:
Preprocessor Example
script:
code: |
def main(params, *args):
# Auto add latency test
for group in params["proxy-groups"]:
if group["type"] == "url-test":
group["url"] = "http://www.gstatic.com/generate_204"
group["interval"] = 300
return params
Scheduled Tasks
Combine with macOS cron or launchd for automation:
- Scheduled subscription updates
- Scheduled node latency tests
- Scheduled configuration backups
- Scheduled log cleanup
Performance Tuning
Reducing Latency
Optimize latency through these configurations:
| Setting | Default | Optimized | Effect |
|---|---|---|---|
| tcp-concurrent | false | true | Concurrent connections, lower latency |
| url-test interval | 600 | 300 | More frequent speed tests |
| dns enhanced-mode | redir-host | fake-ip | Faster DNS resolution |
Reducing Resource Usage
Optimize ClashX resource usage:
- Disable unnecessary logging (log-level: warning)
- Reduce rule count, use rule sets instead
- Disable unused proxy protocols
- Regularly clean cache and log files
Network Optimization
Optimization tips for different network environments:
Home Broadband: Enable TCP concurrent
Mobile Network: Reduce test frequency to save data
Corporate Network: Use obfuscation to avoid detection
Monitoring & Debugging
Use Dashboard to monitor performance metrics:
Configuration Optimization Summary
The goal of advanced configuration is to find balance between performance, stability, and functionality. Don't blindly pursue complex configurations - optimize based on actual usage scenarios. Regular review and updates will maintain the best user experience.