File Overview
The config.yaml controls ClashX behavior: ports, nodes, groups, rules, DNS, and TUN. Keep a backup before large edits.
File Location
~/.config/clash/config.yaml
# If using managed subscriptions, profiles are stored under:
~/.config/clash/profiles/
General Section
port: 7890 # HTTP/HTTPS proxy
socks-port: 7891 # SOCKS5
redir-port: 7892 # (optional) redir
allow-lan: true
mode: Rule # Rule / Global / Direct
log-level: info
external-controller: 127.0.0.1:9090
secret: ""
Modes: Rule (recommended), Global (all proxy), Direct (no proxy).
Proxies Section
Define nodes (VMess/VLESS/Trojan/SS/SSR/HTTP). Example:
proxies:
- name: "US-01"
type: vmess
server: us.example.com
port: 443
uuid: YOUR-UUID
alterId: 0
cipher: auto
tls: true
network: ws
ws-opts:
path: /ws
Proxy Groups
Groups control routing choices: select, url-test, fallback, load-balance.
proxy-groups:
- name: Proxy
type: select
proxies:
- Auto
- US-01
- DIRECT
- name: Auto
type: url-test
proxies:
- US-01
- JP-01
url: http://www.gstatic.com/generate_204
interval: 300
Rules
Rule order matters; first match wins.
rules:
- DOMAIN-SUFFIX,apple.com,DIRECT
- DOMAIN-SUFFIX,google.com,Proxy
- GEOIP,CN,DIRECT
- MATCH,Proxy
Common types: DOMAIN-SUFFIX, DOMAIN-KEYWORD, DOMAIN, IP-CIDR, GEOIP, MATCH.
DNS Settings
Recommended: fake-ip for TUN compatibility.
dns:
enable: true
listen: 127.0.0.1:53
enhanced-mode: fake-ip
nameserver:
- 119.29.29.29
- 223.5.5.5
fallback:
- https://1.1.1.1/dns-query
- https://dns.google/dns-query
fallback-filter:
geoip: true
geoip-code: CN
Quick Template
port: 7890
socks-port: 7891
allow-lan: true
mode: Rule
log-level: info
proxies:
- { name: "US-01", type: vmess, server: us.example.com, port: 443, uuid: YOUR-UUID, alterId: 0, cipher: auto, tls: true, network: ws, ws-opts: { path: /ws } }
proxy-groups:
- name: Proxy
type: select
proxies:
- Auto
- DIRECT
rules:
- GEOIP,CN,DIRECT
- MATCH,Proxy
Optimization Tips
- Use url-test for auto latency selection.
- Add DIRECT rules for Apple/local domains to reduce latency.
- Use fake-ip with TUN mode for widest coverage.
- If ports conflict, change
port/socks-portand restart ClashX.
Was this article helpful?
Thanks for your feedback!