RULE ENGINE
Choose direct, proxy, or reject handling based on the target
Rule mode reads rules from top to bottom and hands the connection to the matching proxy group on the first hit. Domain rules suit common websites, IP rules apply when the destination address has already been resolved, and process rules can route a specific app separately. Unlike a system proxy that offers only a global switch, a Clash configuration records matching conditions in a text file, making results easier to review and reuse on phones and computers. Put narrow, high-priority rules first, then use MATCH for remaining traffic.
rules:
- DOMAIN-SUFFIX,example.com,DIRECT
- GEOIP,CN,DIRECT
- MATCH,Proxy
POLICY GROUP
Separate node selection logic from routing rules
Proxy groups form the layer between rules and individual nodes. Manual groups suit situations where you need precise control over the exit; auto-select groups choose an available target using the client’s supported tests; failover groups check candidates in order and switch when the current target is unavailable. Rules reference group names, so changing nodes does not require editing every rule. This structure works better with subscription updates than embedding nodes directly in each rule and keeps configuration responsibilities clear.
proxy-groups:
- name: Proxy
type: select
proxies:
- Auto
- DIRECT
DNS PIPELINE
Keep DNS resolution and rule matching on the same path
DNS settings determine where domains are resolved, how results reach the rule engine, and which fallback path is used when the local network has problems. Fake-IP mode returns a mapped address first, then the core restores the original domain for matching, making it suitable for stable domain rules; redir-host follows a more traditional resolution flow. Also check whether encrypted system DNS, browser-level DNS, and client settings are running in parallel, which can bypass the intended path. When connections work but webpages do not load, DNS is usually worth checking before repeatedly switching nodes.
dns:
enable: true
enhanced-mode: fake-ip
nameserver:
- system
NETWORK STACK
Capture traffic from apps that ignore the system proxy
Some games, command-line tools, and standalone runtimes do not read system proxy settings, so enabling a system proxy alone cannot cover their connections. TUN mode uses a virtual network interface to receive more system traffic, then lets the Clash core apply DNS and routing rules. Coverage is broader, but it depends more heavily on system permissions, routing tables, and the state of other VPN tools. On first enablement, close similar traffic-capture tools, complete every permission prompt, and test the browser, terminal, and target apps one by one to avoid mistaking permission conflicts for node problems.
tun:
enable: true
stack: mixed
auto-route: true
auto-detect-interface: true