新版Clash规则!神机规则到底怎么使用?如何制作自己的Clash配置文件(.yaml)

文章导读目录

前言

以前作者也是为大家带来了一期Clash的教程,只是目前Clash的官方进行了一次较大的更新,导致原先的配置文件用不了。

当然,这次更新让我们更好的拥有了节点订阅的功能,现在我们可以把自己的节点和“鸡场”的节点写在同一个配置文件中了。

今天所用到的规则来自:点击跳转

点击播放

Clash项目及客户端

MAC 版本的 Clash 有 ClashX,并且拥有中文版的。但是作者看到此软件貌似还没有和 Clash 官方同步更新。

所以今天用 Clash Windows 这个软件为大家演示。

(其实大家不用在意这个软件的名字为 Clash Windows,其实它也是有 MacOS 客户端版本的)

Clash 项目地址:点击跳转

Clash Windows 客户端下载:点击跳转

Clash Windows macOS 客户端下载:点击跳转

Clash Windows 0.10.4汉化包:点击下载(7月8日更新) (支持WIN和MAC的CLASH汉化,汉化说明在包内)

Clash Android 客户端下载:点击跳转

注意事项

Clash 不支持 SSR 节点的订阅,若是只有 SSR 的订阅地址,请自行更换 Clash 内核 (ClashR 支持 SSR)

Clash详细配置注释

下面这份配置来自本期视频作者用到的配置文件

友情提示:
下面的配置是作者所用的正常的:
里面包含 V2RAY+WS+TLS 的配置写法,
Trojan 的配置写法,
机场订阅的写法等

大家可以 对照视频 修改为自己的参数,当然也可以访问该规则的项目地址 Copy。

  1. # Port of HTTP(S) proxy server on the local end
  2. port: 7890
  3. # Port of SOCKS5 proxy server on the local end
  4. socks-port: 7891
  5. # Transparent proxy server port for Linux and macOS
  6. # redir-port: 7892
  7. # HTTP(S) and SOCKS5 server on the same port
  8. # mixed-port: 7890
  9. # authentication of local SOCKS5/HTTP(S) server
  10. # authentication:
  11. # - "user1:pass1"
  12. # - "user2:pass2"
  13. # Set to true to allow connections to local-end server from
  14. # other LAN IP addresses
  15. allow-lan: false
  16. # This is only applicable when `allow-lan` is `true`
  17. # '*': bind all IP addresses
  18. # 192.168.122.11: bind a single IPv4 address
  19. # "[aaaa::a8aa:ff:fe09:57d8]": bind a single IPv6 address
  20. bind-address: '*'
  21. # Clash router working mode
  22. # rule: rule-based packet routing
  23. # global: all packets will be forwarded to a single endpoint
  24. # direct: directly forward the packets to the Internet
  25. mode: rule
  26. # Clash by default prints logs to STDOUT
  27. # info / warning / error / debug / silent
  28. log-level: info
  29. # When set to false, resolver won't translate hostnames to IPv6 addresses
  30. ipv6: true
  31. # RESTful web API listening address
  32. external-controller: 127.0.0.1:9090
  33. # A relative path to the configuration directory or an absolute path to a
  34. # directory in which you put some static web resource. Clash core will then
  35. # serve it at `${API}/ui`.
  36. # external-ui: folder
  37. # Secret for the RESTful API (optional)
  38. # Authenticate by spedifying HTTP header `Authorization: Bearer ${secret}`
  39. # ALWAYS set a secret if RESTful API is listening on 0.0.0.0
  40. # secret: ""
  41. # Outbound interface name
  42. interface-name: en0
  43. # Static hosts for DNS server and connection establishment, only works
  44. # when `dns.enhanced-mode` is `redir-host`.
  45. #
  46. # Wildcard hostnames are supported (e.g. *.clash.dev, *.foo.*.example.com)
  47. # Non-wildcard domain names has a higher priority than wildcard domain names
  48. # e.g. foo.example.com > *.example.com > .example.com
  49. # P.S. +.foo.com equals to .foo.com and foo.com
  50. hosts:
  51. 'mtalk.google.com': 108.177.125.188
  52. # '*.clash.dev': 127.0.0.1
  53. # '.dev': 127.0.0.1
  54. # 'alpha.clash.dev': '::1'
  55. # DNS server settings
  56. # This section is optional. When not present, DNS server will be disabled.
  57. dns:
  58. enable: false
  59. listen: 0.0.0.0:53
  60. # ipv6: false # when false, response to AAAA questions will be empty
  61. # These nameservers are used to resolve the DNS nameserver hostnames below.
  62. # Specify IP addresses only
  63. default-nameserver:
  64. - 114.114.114.114
  65. - 8.8.8.8
  66. enhanced-mode: redir-host # or fake-ip
  67. fake-ip-range: 198.18.0.1/16 # Fake IP addresses pool CIDR
  68. # Hostnames in this list will not be resolved with fake IPs
  69. # i.e. questions to these domain names will always be answered with their
  70. # real IP addresses
  71. # fake-ip-filter:
  72. # - '*.lan'
  73. # - localhost.ptlogin2.qq.com
  74. # Supports UDP, TCP, DoT, DoH. You can specify the port to connect to.
  75. # All DNS questions are sent directly to the nameserver, without proxies
  76. # involved. Clash answers the DNS question with the first result gathered.
  77. nameserver:
  78. - 114.114.114.114 # default value
  79. - 8.8.8.8 # default value
  80. - tls://dns.rubyfish.cn:853 # DNS over TLS
  81. - https://1.1.1.1/dns-query # DNS over HTTPS
  82. # When `fallback` is present, the DNS server will send concurrent requests
  83. # to the servers in this section along with servers in `nameservers`.
  84. # The answers from fallback servers are used when the GEOIP country
  85. # is not `CN`.
  86. # fallback:
  87. # - tcp://1.1.1.1
  88. # If IP addresses resolved with servers in `nameservers` are in the specified
  89. # subnets below, they are considered invalid and results from `fallback`
  90. # servers are used instead.
  91. #
  92. # IP address resolved with servers in `nameserver` is used when
  93. # `fallback-filter.geoip` is true and when GEOIP of the IP address is `CN`.
  94. #
  95. # If `fallback-filter.geoip` is false, results from `fallback` nameservers
  96. # are always used, and answers from `nameservers` are discarded.
  97. #
  98. # This is a countermeasure against DNS pollution attacks.
  99. fallback-filter:
  100. geoip: true
  101. ipcidr:
  102. # - 240.0.0.0/4
  103. proxies:
  104. # 支持的协议及加密算法示例请查阅 Clash 项目 README 以使用最新格式:https://github.com/Dreamacro/clash/blob/master/README.md
  105. # VMess(Websocket + TLS)
  106. - name: "测试V2RAY"
  107. type: vmess
  108. server: test.bozai.us
  109. port: 443
  110. uuid: 6d499645-649f-48c7-9841-424b3c955fa6
  111. alterId: 22
  112. cipher: auto
  113. # udp: true
  114. tls: true
  115. # skip-cert-verify: true
  116. network: ws
  117. ws-path: /10e0521eb4/
  118. # ws-headers:
  119. # Host: v2ray.com
  120. # Trojan
  121. - name: "Trojan测试"
  122. type: trojan
  123. server: test1.bozai.us
  124. port: 443
  125. password: TRadayie
  126. # udp: true
  127. # sni: example.com # aka server name
  128. # alpn:
  129. # - h2
  130. # - http/1.1
  131. # skip-cert-verify: true
  132. # 服务器节点订阅
  133. proxy-providers:
  134. # name: # Provider 名称
  135. # type: http # http 或 file
  136. # path: # 文件路径
  137. # url: # 只有当类型为 HTTP 时才可用,您不需要在本地空间中创建新文件。
  138. # interval: # 自动更新间隔,仅在类型为 HTTP 时可用
  139. # health-check: # 健康检查选项从此处开始
  140. # enable:
  141. # url:
  142. # interval:
  143. #
  144. # 「url」参数填写订阅链接
  145. #
  146. # 订阅链接可以使用 API 进行转换,如:https://sub.dler.io/
  147. #
  148. # 1.模式选择「进阶模式」 2.填写订阅链接 3.勾选「输出为 Node List」 4.「生成订阅链接」
  149. #
  150. SuYing666-Sub: # 速鹰666 https://goii.cc/666 机场订阅链接
  151. type: http
  152. url: "https://api.dler.io/sub?target=clash&url=https%3A%2F%2Fdingyue.suying666.info%2Flink%2F1VQMsXdKlJ5E2jFV%3Fsub%3D3&emoji=false&list=true&udp=false&tfo=false&scv=false&fdn=false&sort=false"
  153. interval: 3600
  154. path: ./Proxy/ProxyList.yaml # 不同机场不同命名
  155. health-check:
  156. enable: true
  157. interval: 600
  158. url: http://www.gstatic.com/generate_204
  159. SuYing777-Sub: # 速鹰666 https://goii.cc/666 机场订阅链接
  160. type: http
  161. url: "https://api.dler.io/sub?target=clash&url=https%3A%2F%2Fdingyue.suying666.info%2Flink%2F1VQMsXdKlJ5E2jFV%3Fsub%3D3&emoji=false&list=true&udp=false&tfo=false&scv=false&fdn=false&sort=false"
  162. interval: 3600
  163. path: ./Proxy/ProxyList.yaml # 不同机场不同命名
  164. health-check:
  165. enable: true
  166. interval: 600
  167. url: http://www.gstatic.com/generate_204
  168. proxy-groups:
  169. # 策略组示例请查阅 Clash 项目 README 以使用最新格式:https://github.com/Dreamacro/clash/blob/master/README.md
  170. #
  171. # 策略组说明
  172. #
  173. # 「MATCH」类似 Surge 的「Final」,此处用于选择白名单模式(PROXY 策略)和黑名单模式(DIRECT 策略)
  174. #
  175. # 「Streaming」和「StreamingSE」比较好理解,有专用于流媒体的节点就设置到其中,如果没有「StreamingSE」的需求可以连带 Rule 部分一起删掉,「Streaming」需至少保留 Rule,用「PROXY」即可。
  176. #
  177. # 「PROXY」是代理规则策略,它可以指定为某个节点或嵌套一个其他策略组,如:「自动测试」、「Fallback」或「负载均衡」的策略组,关于这 3 个策略组的具体示例可以看官方示例:https://github.com/Dreamacro/clash
  178. #
  179. # Fallback 比较实用的策略组类型,用于测试服务器节点的可用性,当第一个节点不可用时切换到第二个,以此类推。
  180. - name: "Fallback"
  181. type: fallback
  182. proxies:
  183. - 测试V2RAY
  184. - Trojan测试
  185. url: 'http://www.gstatic.com/generate_204'
  186. interval: 300
  187. # 代理节点选择
  188. - name: "PROXY"
  189. type: select
  190. proxies:
  191. - Fallback
  192. - 测试V2RAY
  193. - Trojan测试
  194. - SuYing666
  195. - SuYing777
  196. # 白名单模式 PROXY, 黑名单模式 DIRECT, 不知道别动
  197. - name: "MATCH"
  198. type: select
  199. proxies:
  200. - PROXY
  201. - DIRECT
  202. # 国际流媒体服务
  203. - name: "Streaming"
  204. type: select
  205. proxies:
  206. - PROXY
  207. - 测试V2RAY
  208. - Trojan测试
  209. # 中国流媒体服务(面向海外版本)
  210. - name: "StreamingSE"
  211. type: select
  212. proxies:
  213. - DIRECT
  214. - 测试V2RAY
  215. - Trojan测试
  216. # 手动选择节点订阅
  217. - name: "SuYing666"
  218. type: select # 亦可使用 fallback 或 load-balance
  219. use:
  220. - SuYing666-Sub
  221. - name: "SuYing777"
  222. type: select # 亦可使用 fallback 或 load-balance
  223. use:
  224. - SuYing777-Sub
  225. # 关于 Rule Provider 请查阅:https://lancellc.gitbook.io/clash/clash-config-file/rule-provider
  226. rule-providers:
  227. # name: # Provider 名称
  228. # type: http # http 或 file
  229. # behavior: classical # 或 ipcidr、domain
  230. # path: # 文件路径
  231. # url: # 只有当类型为 HTTP 时才可用,您不需要在本地空间中创建新文件。
  232. # interval: # 自动更新间隔,仅在类型为 HTTP 时可用
  233. Unbreak:
  234. type: http
  235. behavior: classical
  236. path: ./RuleSet/Unbreak.yaml
  237. url: https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/RuleSet/Unbreak.yaml
  238. interval: 86400
  239. Streaming:
  240. type: http
  241. behavior: classical
  242. path: ./RuleSet/StreamingMedia/Streaming.yaml
  243. url: https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/RuleSet/StreamingMedia/Streaming.yaml
  244. interval: 86400
  245. StreamingSE:
  246. type: http
  247. behavior: classical
  248. path: ./RuleSet/StreamingMedia/StreamingSE.yaml
  249. url: https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/RuleSet/StreamingMedia/StreamingSE.yaml
  250. interval: 86400
  251. Global:
  252. type: http
  253. behavior: classical
  254. path: ./RuleSet/Global.yaml
  255. url: https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/RuleSet/Global.yaml
  256. interval: 86400
  257. China:
  258. type: http
  259. behavior: classical
  260. path: ./RuleSet/China.yaml
  261. url: https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/RuleSet/China.yaml
  262. interval: 86400
  263. ChinaIP:
  264. type: http
  265. behavior: ipcidr
  266. path: ./RuleSet/Extra/ChinaIP.yaml
  267. url: https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/RuleSet/Extra/ChinaIP.yaml
  268. interval: 86400
  269. # 规则
  270. rules:
  271. # Unbreak
  272. - RULE-SET,Unbreak,DIRECT
  273. # Global Area Network
  274. # (Streaming Media)
  275. - RULE-SET,Streaming,Streaming
  276. # (StreamingSE)
  277. - RULE-SET,StreamingSE,StreamingSE
  278. # (DNS Cache Pollution) / (IP Blackhole) / (Region-Restricted Access Denied) / (Network Jitter)
  279. - RULE-SET,Global,PROXY
  280. # China Area Network
  281. - RULE-SET,China,DIRECT
  282. # Local Area Network
  283. - IP-CIDR,192.168.0.0/16,DIRECT
  284. - IP-CIDR,10.0.0.0/8,DIRECT
  285. - IP-CIDR,172.16.0.0/12,DIRECT
  286. - IP-CIDR,127.0.0.0/8,DIRECT
  287. - IP-CIDR,100.64.0.0/10,DIRECT
  288. - IP-CIDR,224.0.0.0/4,DIRECT
  289. # (可选)使用来自 ipipdotnet 的 ChinaIP 以解决数据不准确的问题,使用 ChinaIP.yaml 时可禁用下列直至(包括)「GEOIP,CN」规则
  290. # - RULE-SET,ChinaIP,DIRECT
  291. # Tencent
  292. - IP-CIDR,119.28.28.28/32,DIRECT
  293. - IP-CIDR,182.254.116.0/24,DIRECT
  294. # GeoIP China
  295. - GEOIP,CN,DIRECT
  296. - MATCH,MATCH

About The Author

技术教程

Clash一键生成强大的分流规则,支持自建后端订阅转换。自己汉化Clash for Windows,支持Win/MacOS平台

2021-1-7 15:39:49

技术教程

VPS挂载谷歌云盘,用Emby实现云盘媒体文件在线播放。免搜刮元数据,部署自带封面图。兼容全平台、全客户端

2021-1-7 15:40:26

搜索