-
安装Clash:
- 在macOS上使用Homebrew安装:
brew install clash
- 启动Clash:
clash start
- Clash会自动生成配置文件,通常位于
~/.clash/config.json。
- 在macOS上使用Homebrew安装:
-
编辑配置文件:
- 打开配置文件
clash_config.json,使用编辑器如Visual Studio Code。 - 配置示例:
{ "rule": [ { "domain": "google.com", "port": 80, "protocol": "http", "timeout": 500, "connect": "api.google.com" } ], "dns": "8.20.113.10" }rule数组:定义要代理的规则。domain:目标域名或IP。port:目标端口。protocol:协议(http/https)。timeout:超时时间(毫秒)。connect:代理到目标地址。
dns:指定DNS服务器地址。
- 打开配置文件
-
配置DNS:
- 修改Clash配置中的
dns为Cloudflare的DNS服务器地址:"dns": "8.20.113.10",
- 在系统设置中设置DNS为
1.1.1以支持DNS过滤。
- 修改Clash配置中的
-
启动Clash:
- 使用
clash start启动服务。
- 使用
-
测试配置:
- 打开浏览器,访问
http://localhost:789,检查Clash界面是否正常。 - 测试被代理的网站,如Google,确认是否成功。
- 打开浏览器,访问
-
验证和故障排除:
- 使用
clash -version查看版本,clash -check验证配置。 - 检查Clash日志,解决可能的错误。
- 使用
通过以上步骤,你可以配置并使用Clash来管理网络请求,实现域名和端口的重定向。









