🚀 开源 · 跨平台 · 高性能 🚀 Open Source · Cross-Platform · High Performance

Clash — 跨平台、高性能网络代理工具 Clash — Cross-Platform High-Performance Proxy Tool

基于规则的多协议代理内核,为改善互联网体验而生。支持 Windows、macOS、iOS、Android、OpenWrt 等多平台部署。 A rule-based multi-protocol proxy kernel, built for a better internet experience. Deployable on Windows, macOS, iOS, Android, OpenWrt and more.

核心功能亮点Core Features

Clash 提供全面的网络代理能力,满足从入门到专业的所有需求 Comprehensive proxy capabilities for everyone, from beginners to professionals

🔌

多协议支持Multi-Protocol Support

入站支持 HTTP/HTTPS/SOCKS5/TUN,出站支持 Shadowsocks、VMess、Trojan、Snell、WireGuard 等主流协议。Inbound: HTTP/HTTPS/SOCKS5/TUN. Outbound: Shadowsocks, VMess, Trojan, Snell, WireGuard and more.

🧭

基于规则的路由Rule-Based Routing

支持动态脚本、域名、IP 地址、进程名称等多种路由匹配方式,灵活分流网络流量。Dynamic scripts, domain, IP, process name matching for flexible traffic routing.

🛡️

Fake-IP DNSFake-IP DNS

减少 DNS 污染影响,通过伪造 IP 响应提升网络性能与解析速度。Reduce DNS pollution impact and boost network performance with forged IP responses.

🔄

透明代理Transparent Proxy

使用自动路由表/规则管理 Redirect TCP 和 TProxy TCP/UDP,实现无感代理。Auto route-table/rule management for Redirect TCP and TProxy TCP/UDP seamless proxying.

⚖️

策略组 Proxy GroupsProxy Groups

支持自动可用性测试(fallback)、负载均衡(load balance)、延迟测试(url-test)等策略。Auto fallback, load balancing, URL latency testing and more proxy group strategies.

📡

RESTful APIRESTful API

通过 API 就地更新配置,实现自动化管理与集成,便于开发运维场景使用。Update configurations in-place via API for automated management and DevOps integration.

全平台下载Download for All Platforms

选择您的平台,获取 Clash 客户端。标注"跳转至外部商店"的链接将引导至第三方应用商店。 Choose your platform to get the Clash client. Links marked with "External Store" will redirect to third-party app stores.

🪟 Clash for Windows
Premium SHA256
下载 Windows 版Download for Windows
🍎 Stash (Clash for iOS)
Premium 跳转至外部商店External Store
前往 App StoreGo to App Store
🤖 Clash for Android
Premium SHA256
下载 Android 版Download for Android
💻 Stash for macOS
Premium
前往 Mac App StoreGo to Mac App Store
🖥️ ClashX Pro
Premium
下载 ClashX ProDownload ClashX Pro
📡 OpenClash
OpenWrt 插件OpenWrt Plugin
下载 OpenClashDownload OpenClash

版本对比Version Comparison

了解开源版(OSS)与 Premium 版的功能差异 Understand the differences between OSS and Premium editions

功能特性Feature 开源版 (OSS)OSS Edition Premium
多协议代理Multi-Protocol Proxy
基于规则的路由Rule-Based Routing
Fake-IP DNSFake-IP DNS
RESTful APIRESTful API
透明代理 (TProxy)Transparent Proxy (TProxy)
TUN 模式TUN Mode
Script 脚本路由Script Routing
Rule ProviderRule Provider

仅限 Premium 版本可用 Available only in Premium edition

文档与资源Docs & Resources

常见问题Frequently Asked Questions

关于 Clash 的安装、配置与使用的 6 个核心问题解答 6 essential questions about installing, configuring and using Clash

1. 如何在不同平台上安装和配置 Clash? 1. How to install and configure Clash on different platforms?

安装配置 Clash 的步骤如下:

  1. 选择合适的客户端:根据您的操作系统访问本页下载矩阵,Windows 用户推荐 Clash for Windows,macOS 用户可选择 Stash 或 ClashX Pro,移动端用户可选用 Stash(iOS)或 Clash for Android。
  2. 下载并安装:点击对应平台的下载按钮,获取最新版本安装包。对于 GitHub 发布的版本,建议验证 SHA256 校验值以确保文件完整性。
  3. 获取配置文件:准备一份 YAML 格式的 Clash 配置文件,其中包含代理服务器信息、规则路由和 DNS 设置。您可以从节点订阅平台获取,或自行编写。
  4. 导入配置:打开客户端,通过界面导入配置文件(通常支持本地文件导入或订阅链接导入)。客户端会自动解析配置并启动代理服务。
  5. 验证连接:启动代理后访问测试页面确认网络连通性,检查规则路由是否按预期工作。如遇问题可查阅官方 Wiki 或社区讨论区寻求帮助。

Steps to install and configure Clash:

  1. Choose the right client: Refer to the download matrix on this page. Windows users should choose Clash for Windows; macOS users can select Stash or ClashX Pro; mobile users can use Stash (iOS) or Clash for Android.
  2. Download and install: Click the download button for your platform to get the latest package. For GitHub releases, verify the SHA256 checksum to ensure file integrity.
  3. Obtain a configuration file: Prepare a YAML-format Clash config file containing proxy server info, routing rules, and DNS settings. You can get one from subscription platforms or write your own.
  4. Import the configuration: Open the client and import the config file via the interface (usually supports local file import or subscription URL import). The client will parse it and start the proxy service automatically.
  5. Verify connectivity: After starting the proxy, visit a test page to confirm network connectivity and check that routing rules work as expected. Consult the official Wiki or community if issues arise.
2. Clash 支持哪些代理协议?各协议有何特点? 2. Which proxy protocols does Clash support and what are their characteristics?

Clash 支持的协议及特点如下:

  1. Shadowsocks (SS):经典的加密代理协议,轻量高效,适合在受限网络环境中使用。Clash 支持多种 SS 加密方法,包括 AEAD 系列以保证数据完整性。
  2. VMess:V2Ray 核心协议,提供强大的混淆能力和灵活的传输层选项,适合需要高度隐匿的场景。Clash 完整支持 VMess 的 TCP 和 WebSocket 传输。
  3. Trojan:模拟 HTTPS 流量以绕过深度包检测(DPI),将代理流量伪装成正常的 HTTPS 通信。Clash 对 Trojan 协议的支持使其在严格审查网络下依然可用。
  4. Snell:专为 Surge 生态设计的轻量级加密协议,延迟低、开销小。Clash Premium 版完整支持 Snell v3/v4 协议。
  5. WireGuard:现代 VPN 协议,以内核级的高性能和简洁的代码著称。Clash 支持 WireGuard 出站,适合需要高速稳定连接的场景。

Protocols supported by Clash and their characteristics:

  1. Shadowsocks (SS): A classic lightweight encrypted proxy protocol, ideal for restricted networks. Clash supports multiple SS encryption methods including AEAD ciphers for data integrity.
  2. VMess: The core V2Ray protocol offering robust obfuscation and flexible transport options, suitable for scenarios requiring high anonymity. Clash fully supports VMess over TCP and WebSocket.
  3. Trojan: Mimics HTTPS traffic to bypass deep packet inspection (DPI), disguising proxy traffic as normal HTTPS communication. Clash's Trojan support ensures usability under strict censorship.
  4. Snell: A lightweight encrypted protocol designed for the Surge ecosystem with low latency and minimal overhead. Clash Premium fully supports Snell v3/v4.
  5. WireGuard: A modern VPN protocol known for kernel-level high performance and clean code. Clash supports WireGuard outbound for high-speed stable connections.
3. 如何编写 Clash 的规则路由配置以实现智能分流? 3. How to write Clash routing rules for intelligent traffic splitting?

编写规则路由配置的步骤:

  1. 理解规则结构:Clash 规则由 rules 字段定义,每条规则包含匹配类型、匹配值和目标策略组。规则按从上到下的顺序依次匹配,命中即停止。
  2. 选择匹配类型:支持 DOMAIN(精确域名)、DOMAIN-SUFFIX(域名后缀)、DOMAIN-KEYWORD(域名关键词)、GEOIP(地理位置)、IP-CIDR(IP 段)、PROCESS-NAME(进程名)等多种匹配方式。
  3. 定义策略组:proxy-groups 中创建策略组(如"代理"、"直连"、"自动选择"),并将它们作为规则的匹配目标。
  4. 编写规则列表:将常用国内域名设为 DIRECT(直连),将需要代理的域名指向代理策略组,最后使用 MATCH 规则作为兜底。
  5. 测试与优化:启用日志模式观察规则匹配情况,使用 url-test 策略组自动选择延迟最低的节点,持续优化规则顺序和匹配逻辑。

Steps to write routing rule configurations:

  1. Understand rule structure: Clash rules are defined in the rules field. Each rule includes a match type, match value, and target proxy group. Rules are evaluated top-to-bottom; the first match wins.
  2. Choose match types: Supported types include DOMAIN, DOMAIN-SUFFIX, DOMAIN-KEYWORD, GEOIP, IP-CIDR, PROCESS-NAME, and more.
  3. Define proxy groups: Create proxy groups in proxy-groups (e.g., "Proxy", "Direct", "Auto-Select") and reference them as rule targets.
  4. Write the rule list: Set common domestic domains to DIRECT, point overseas domains to a proxy group, and use a final MATCH rule as the fallback.
  5. Test and optimize: Enable logging to observe rule matching behavior, use url-test groups to auto-select the lowest-latency node, and continuously refine rule ordering.
4. Fake-IP DNS 是如何工作的?它有什么优势? 4. How does Fake-IP DNS work and what are its advantages?

Fake-IP DNS 的工作原理与优势:

  1. 拦截 DNS 请求:当客户端发起 DNS 查询时,Clash 会拦截该请求,不将其转发至上游 DNS 服务器进行真实解析。
  2. 返回伪造 IP:Clash 从预先分配的 IP 地址池中返回一个伪造的 IP 地址给客户端,同时记录该伪造 IP 与真实域名的映射关系。
  3. 建立连接时查询:当客户端使用该伪造 IP 发起实际连接时,Clash 根据映射表还原真实域名,再通过代理服务器进行连接。
  4. 减少 DNS 污染:由于 DNS 解析被本地化处理,避免了中间网络设备对 DNS 查询的干扰和污染,特别适合在存在 DNS 劫持的网络环境中使用。
  5. 提升性能:Fake-IP 模式减少了 DNS 解析的网络往返次数,显著加快了域名首次访问速度,同时降低了延迟感知。

How Fake-IP DNS works and its advantages:

  1. Intercept DNS requests: When a client initiates a DNS query, Clash intercepts the request instead of forwarding it to an upstream DNS server for real resolution.
  2. Return a fake IP: Clash returns a forged IP from a pre-allocated address pool to the client while recording the mapping between the fake IP and the real domain name.
  3. Resolve on connection: When the client establishes an actual connection using the fake IP, Clash restores the real domain from its mapping table and connects through the proxy server.
  4. Reduce DNS pollution: Since DNS resolution is handled locally, interference and pollution from intermediate network devices are avoided—especially useful in networks with DNS hijacking.
  5. Improve performance: Fake-IP mode reduces DNS round trips, significantly speeding up first-time domain access and lowering perceived latency.
5. 什么是代理策略组(Proxy Groups)?如何合理配置? 5. What are Proxy Groups and how to configure them properly?

代理策略组的类型与配置方法:

  1. 了解策略组类型:Clash 支持多种策略组类型,包括 select(手动选择)、url-test(延迟测试自动选优)、fallback(可用性回退)、load-balance(负载均衡)和 relay(链式代理)。
  2. select 手动选择:最基础的类型,用户从节点列表中手动选取一个节点使用,适合需要固定出口 IP 的场景。
  3. url-test 自动测试:定期对组内所有节点进行延迟测试,自动切换到延迟最低的节点,适合追求最佳速度的用户。
  4. fallback 可用性回退:按优先级顺序尝试节点,当前一个节点不可用时自动切换到下一个,确保连接的高可用性。
  5. load-balance 负载均衡:将流量分散到多个节点上,避免单一节点过载,适合大流量场景下的稳定使用。

Proxy Group types and configuration methods:

  1. Understand group types: Clash supports select (manual), url-test (auto latency-based), fallback (availability failover), load-balance, and relay (chained proxy) group types.
  2. Select - manual choice: The most basic type—users manually pick one node from the list, suitable for scenarios requiring a fixed exit IP.
  3. url-test - auto testing: Periodically tests latency for all nodes in the group and automatically switches to the lowest-latency node, ideal for speed-conscious users.
  4. fallback - availability failover: Tries nodes in priority order and automatically switches to the next when the current one fails, ensuring high availability.
  5. load-balance: Distributes traffic across multiple nodes to prevent overloading a single node, suitable for high-traffic stable usage.
6. 遇到连接问题应该如何排查?有什么常见解决方案? 6. How to troubleshoot connection issues? What are common solutions?

连接问题的排查步骤与解决方案:

  1. 检查客户端状态:确认 Clash 客户端已正常启动,系统代理设置已正确配置。查看客户端日志面板是否有报错信息,特别关注配置文件解析错误。
  2. 验证节点可用性:使用客户端的延迟测试功能检查各节点连通性。如果所有节点超时,可能是网络环境阻断或节点已失效,尝试更换节点或更新订阅。
  3. 检查规则路由:在日志中观察目标域名的匹配规则,确认流量是否被正确地导向了预期的代理策略组。错误的规则可能导致流量走直连而无法访问。
  4. 排查 DNS 问题:如果域名解析异常,尝试切换 DNS 模式(如从 Fake-IP 切换到 Redir-Host),或更换上游 DNS 服务器地址。
  5. 重置与重试:如果以上步骤均无效,尝试重启客户端、重新导入配置文件,或使用默认配置模板进行最小化测试以隔离问题根源。

Troubleshooting steps and common solutions for connection issues:

  1. Check client status: Ensure the Clash client is running and system proxy settings are correctly configured. Review the client log panel for errors, especially config file parsing errors.
  2. Verify node availability: Use the client's latency test feature to check each node's connectivity. If all nodes time out, the network may be blocking them or nodes may be expired—try switching nodes or updating subscriptions.
  3. Check routing rules: Observe which rule matches the target domain in the logs, and confirm traffic is correctly directed to the intended proxy group. Incorrect rules may cause traffic to go direct and fail to connect.
  4. Troubleshoot DNS issues: If domain resolution is abnormal, try switching DNS modes (e.g., from Fake-IP to Redir-Host) or changing the upstream DNS server address.
  5. Reset and retry: If all else fails, try restarting the client, re-importing the config file, or using a default config template for minimal testing to isolate the root cause.