`Clash` 是一个跨平台代理工具,通常用来绕过网络限制或隐私保护。它支持多种类型的代理协议,如 Shadowsocks, Vmess, Trojan 等。在 Linux 上使用 Clash 需要按照以下步骤进行:
安装 Clash
1. 从官方网站下载 Clash
下载 Clash 的最新版本,你可以在 [Clash 官方 GitHub 仓库](https://github.com/Dreamacro/clash/releases)找到适合你系统的可执行文件。
bash
wget https://github.com/Dreamacro/clash/releases/download/vX.X.X/clash-linux-amd64-vX.X.X.gz
请替换 `vX.X.X` 为最新的版本号。
2. 解压下载的文件
bash
gunzip clash-linux-amd64-vX.X.X.gz
3. 将 Clash 文件移动到你的 PATH 中
bash
chmod +x clash-linux-amd64-vX.X.X
sudo mv clash-linux-amd64-vX.X.X /usr/local/bin/clash
配置 Clash
1. 创建配置文件
在 `~/.config/clash/` 目录下创建 `config.yaml` 文件。你可以参考官方配置文件模板进行配置,或者直接使用已有的配置文件。
bash
mkdir -p ~/.config/clash
nano ~/.config/clash/config.yaml
2. 编写或导入配置
一个简单的配置文件示例:
yaml
port: 7890
socks-port: 7891
allow-lan: false
mode: Rule
log-level: info
proxies:
- name: "your_prox_example"
type: ss
server: your_server_ip
port: 8388
cipher: your_cipher
password: your_password
proxy-groups:
- name: "Proxy"
type: select
proxies:
- your_prox_example
rules:
- GEOIP, cn, DIRECT
- MATCH, Proxy
运行 Clash
1. 直接在终端运行
bash
clash
2. 后台运行
为了方便,可以将 Clash 作为后台服务运行:
bash
nohup clash &> clash.log &
这将使 Clash 在后台运行,并将输出日志写入 `clash.log` 文件。
设置系统代理
为了使所有流量通过 Clash 代理,需要在系统中设置代理。
CLI 设置代理
1. 临时设置
bash
export http_proxy="http://localhost:7890"
export https_proxy="http://localhost:7890"
export ALL_PROXY="socks5://localhost:7891"
2. 持久性设置
添加代理配置到 `~/.bashrc` 或 `~/.zshrc` 文件中:
bash
echo 'export http_proxy="http://127.0.0.1:7890"' >> ~/.bashrc
echo 'export https_proxy="http://127.0.0.1:7890"' >> ~/.bashrc
echo 'export ALL_PROXY="socks5://127.0.0.1:7891"' >> ~/.bashrc
source ~/.bashrc
通过以上步骤,你应该已经成功在 Linux 上安装并配置了 Clash 代理工具。享受更自由的网络体验吧!如果有其他疑问或需要进一步的帮助,请告诉我。
查看详情
查看详情