安装Clash
根据你的操作系统选择相应的安装方法:
1 Windows
- 下载并安装 Clash for Windows。
- 解压并运行
clash.exe。
2 Linux
- 使用包管理器安装(如 Debian/Ubuntu):
sudo apt-get install clash
- 或者从源码编译安装:
# 克隆仓库 git clone https://github.com/Lee-Soft/Clash.git # 进入目录并编译 cd Clash make sudo make install
3 macOS
- 使用 Homebrew 安装:
brew install clash
- 或者从源码编译:
git clone https://github.com/Lee-Soft/Clash.git cd Clash make ./clash -d
配置Clash
启动 Clash 后,进入配置界面:
- Windows:运行
clash.exe,点击“配置”按钮。 - Linux:在终端中运行
clash。 - macOS:在终端中运行
./clash
1 核心配置
- 绑定地址:设置代理接收请求的地址和端口。
"L": "...:789" // 绑定地址
- 监听地址:指定 Clash监听的地址。
"listen": "...:789" // 监听地址
- 最大并发连接数:设置连接数限制。
"max-connections": 100 // 最大并发连接数
2 高级配置
- 规则转发:定义请求转发规则。
"rules": [ { "destination": "example.com", "source": "...:80", "to": "10...1:80" } ] - 负载均衡:设置多个节点的负载均衡。
"load-balancing": { "algorithm": "rr", "nodes": ["node1", "node2"] } - 速率限制:限制单个连接的速率。
"rate": { "limit": 100, "burst": 100, "time": 100 }
3 Filter链
- 定义过滤规则,阻止特定请求。
"filters": [ { "name": "banned-sites", "url": "www.example.com" } ]
使用示例
- 简单转发:
{ "L": "...:789", "proxy": "http://10...1:789", "listen": "...:789" } - 多节点负载均衡:
{ "L": "...:789", "proxy": "http://node1:789,http://node2:789", "nodes": ["node1", "node2"], "load-balancing": { "algorithm": "rr", "nodes": ["node1", "node2"] } }
注意事项
- 性能优化:调整最大并发连接数和速率限制。
- 高负载处理:在高负载情况下,增加节点数或优化规则。
- 安全设置:确保Clash运行在受信任的网络环境中。
通过以上配置,你可以根据需求灵活调整Clash的行为,充分发挥其强大功能。









