Post

安装并使用Linux下的clash

使用clash进行配置。实际上网上许多教程都比较全面简洁,并不难。

获取文件

clash release页面wget最新的ARM64 .gz文件。

ARM64即ARMv8,因为它是第一版真正支持64位的指令集。

使用gunzip解压该文件,更改名字为clash并chmod u+x clash获取权限。zsh的extract在这里不好用,它一直在尝试将其解压为一个文件夹,不知道为什么。

尝试运行clash,如果.mmdb文件下载失败,前往另一repo下载该文件,用以识别IP地址。

从机场的订阅链接curl -O config.yaml URL即可下载配置文件,或者也可以从clash的GUI右键配置文件scp过来。它长得大概像这样

配置

以下操作均需sudo

把clash cp/usr/local/bin.mmdbconfig.yaml cp/etc下的新文件夹,如/etc/clash

将以下内容添加为/etc/systemd/system/clash.service

1
2
3
4
5
6
7
8
9
10
11
12
[Unit]
Description=Clash daemon, A rule-based proxy in Go.
After=network-online.target

[Service]
Type=simple
Restart=always
# The executable, and file dir
ExecStart=/usr/local/bin/clash -d /etc/clash

[Install]
WantedBy=multi-user.target

运行代理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Reload systemd
systemctl daemon-reload

# Launch clash-daemon on startup
systemctl enable clash

# Launch clash
systemctl start clash

# Status and log check
systemctl status clash
journalctl -xe

# 启用代理
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890

# 禁用代理
unset  http_proxy  https_proxy  all_proxy

其它

不妨试试这个封装好的项目

如果53端口被systemd-resolveddnsmasq占用,修改config.yaml中的DNS监听端口为其它数值即可。

TODO: 为什么?

使用ping来测试代理并不合适,或者说根本没用。curl -L一个原本无法访问的网站比较可靠。

TODO: 为什么?

This post is licensed under CC BY 4.0 by the author.