OpenClash¶
官方wiki: OpenClash Wiki
配置文件¶
配置文件的组成主要分为:基本设置、服务器信息、服务器分组信息、规则(对应服务器分组),各个部分顺序不可调换,否则会造成OpenClash功能异常。
# 此部分您可直接覆盖到配置文件,无需更改
# port of HTTP
port: 7890 # HTTP代理监听端口,此项须在全局设置页面修改
# port of SOCKS5
socks-port: 7891 # SOCKS5代理监听端口,此项须在全局设置页面修改
# redir port for Linux and macOS
redir-port: 7892 # 流量转发监听端口,此项须在全局设置页面修改
allow-lan: true # 此项将被接管为true,不允许修改
# Only applicable when setting allow-lan to true
# "*": bind all IP addresses
# 192.168.122.11: bind a single IPv4 address
# "[aaaa::a8aa:ff:fe09:57d8]": bind a single IPv6 address
bind-address: "*" # HTTP(S)\SOCKS5 监听地址,此项将被接管为all,不允许修改
# Rule / Global/ Direct (default is Rule) # 代理模式:规则、全局、全局直连,您可在此修改或在外部控制(Dashboard)中任意切换
mode: Rule
# set log level to stdout (default is info)
# info / warning / error / debug / silent # 日志输出选项,按需选择,您可在此修改或在外部控制(Dashboard)中任意切换
log-level: info
# A RESTful API for clash
external-controller: 0.0.0.0:9090 # 外部控制监听端口,此项须在外部控制页面修改
# you can put the static web resource (such as clash-dashboard) to a directory, and clash would serve in `${API}/ui`
# input is a relative path to the configuration directory or an absolute path
external-ui: "/usr/share/openclash/dashboard" # Dashboard文件本地地址,此项OpenClash会自动修改
# Secret for RESTful API (Optional)
secret: '123456' # 外部控制登录秘钥,此项须在外部控制页面修改
# experimental feature
experimental: # 是否忽略DNS解析失败,按需选择
ignore-resolve-fail: true # ignore dns resolve fail, default value is true
# authentication of local SOCKS5/HTTP(S) server
authentication: # 设置SOCKS5/HTTP(S)代理的验证信息,须在接管设置页面添加,OpenClash将自动删除自带设置
- "user1:pass1"
- "user2:pass2"
dns: # 如订阅配置无包括此项的所有DNS设置,OpenClash将自动添加
enable: true # set true to enable dns (default is false) # 此项将被接管为true
ipv6: false # default is false # 此项将被接管
listen: 0.0.0.0:53 # 端口为53时将被接管为7874
enhanced-mode: redir-host # or fake-ip # 此项将被接管
fake-ip-range: 198.18.0.1/16 # if you don't know what it is, don't change it # 此项将被接管
# experimental hosts, support wildcard (e.g. *.clash.dev Even *.foo.*.example.com)
# static domain has a higher priority than wildcard domain (foo.example.com > *.example.com)
# NOTE: hosts don't work with `fake-ip`
# hosts: # 此项将被接管
# '*.clash.dev': 127.0.0.1
# 'alpha.clash.dev': '::1'
nameserver:
- 114.114.114.114
- tls://dns.rubyfish.cn:853 # dns over tls
- https://1.1.1.1/dns-query # dns over https
fallback: # concurrent request with nameserver, fallback used when GEOIP country isn't CN
- tcp://1.1.1.1
# Openclash 不会对下方服务器设置进行任何更改,请确保设置正确
Proxy: # 代理服务器信息,此参数必须保留,不能删除
# shadowsocks
# The types of cipher are consistent with go-shadowsocks2
# support AEAD_AES_128_GCM AEAD_AES_192_GCM AEAD_AES_256_GCM AEAD_CHACHA20_POLY1305 AES-128-CTR AES-192-CTR AES-256-CTR AES-128-CFB AES-192-CFB AES-256-CFB CHACHA20-IETF XCHACHA20
# In addition to what go-shadowsocks2 supports, it also supports chacha20 rc4-md5 xchacha20-ietf-poly1305
- { name: "ss1", type: ss, server: server, port: 443, cipher: AEAD_CHACHA20_POLY1305, password: "password", udp: true }
# old obfs configuration remove after prerelease
- name: "ss2"
type: ss
server: server
port: 443
cipher: AEAD_CHACHA20_POLY1305
password: "password"
plugin: obfs
plugin-opts:
mode: tls # or http
# host: bing.com
- name: "ss3"
type: ss
server: server
port: 443
cipher: AEAD_CHACHA20_POLY1305
password: "password"
plugin: v2ray-plugin
plugin-opts:
mode: websocket # no QUIC now
# tls: true # wss
# skip-cert-verify: true
# host: bing.com
# path: "/"
# headers:
# custom: value
# vmess
# cipher support auto/aes-128-gcm/chacha20-poly1305/none
- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto }
# with tls
- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto, tls: true }
# with tls and skip-cert-verify
- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto, tls: true, skip-cert-verify: true }
# with ws-path and ws-headers
- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto, network: ws, ws-path: /path, ws-headers: { Host: v2ray.com } }
# with ws + tls
- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto, network: ws, ws-path: /path, tls: true }
# socks5
- { name: "socks", type: socks5, server: server, port: 443 }
# socks5 with authentication
- { name: "socks", type: socks5, server: server, port: 443, username: "username", password: "password" }
# with tls
- { name: "socks", type: socks5, server: server, port: 443, tls: true }
# with tls and skip-cert-verify
- { name: "socks", type: socks5, server: server, port: 443, tls: true, skip-cert-verify: true }
# http
- { name: "http", type: http, server: server, port: 443 }
# http with authentication
- { name: "http", type: http, server: server, port: 443, username: "username", password: "password" }
# with tls (https)
- { name: "http", type: http, server: server, port: 443, tls: true }
# with tls (https) and skip-cert-verify
- { name: "http", type: http, server: server, port: 443, tls: true, skip-cert-verify: true }
# Openclash 不会对下方策略组设置进行任何更改,请确保设置正确
Proxy Group: # 服务器策略组信息,此参数必须保留,不能删除
# url-test select which proxy will be used by benchmarking speed to a URL.
- { name: "auto", type: url-test, proxies: ["ss1", "ss2", "vmess1"], url: "http://www.gstatic.com/generate_204", interval: 300 }
# fallback select an available policy by priority. The availability is tested by accessing an URL, just like an auto url-test group.
- { name: "fallback-auto", type: fallback, proxies: ["ss1", "ss2", "vmess1"], url: "http://www.gstatic.com/generate_204", interval: 300 }
# load-balance: The request of the same eTLD will be dial on the same proxy.
- { name: "load-balance", type: load-balance, proxies: ["ss1", "ss2", "vmess1"], url: "http://www.gstatic.com/generate_204", interval: 300 }
# select is used for selecting proxy or proxy group
# you can use RESTful API to switch proxy, is recommended for use in GUI.
- { name: "Proxy", type: select, proxies: ["ss1", "ss2", "vmess1", "auto"] }
Rule: # 规则设置,此参数必须保留,不能删除
# 如果您将一直使用第三方规则,下方可以留空。
- DOMAIN-SUFFIX,google.com,auto
- DOMAIN-KEYWORD,google,auto
- DOMAIN,google.com,auto
- DOMAIN-SUFFIX,ad.com,REJECT
- IP-CIDR,127.0.0.0/8,DIRECT
# rename SOURCE-IP-CIDR and would remove after prerelease
- SRC-IP-CIDR,192.168.1.201/32,DIRECT
- GEOIP,CN,DIRECT
- DST-PORT,80,DIRECT
- SRC-PORT,7777,DIRECT
# FINAL would remove after prerelease
# you also can use `FINAL,Proxy` or `FINAL,,Proxy` now
- MATCH,auto