如何在ubuntu server上使用clash

以 Ubuntu(amd64)为例

Step 1:从官方仓库下载对应系统的Release

image-20230321152741149

右键复制链接

image-20230321153000176

下载压缩包

1
wget https://github.com/Dreamacro/clash/releases/download/v1.14.0/clash-linux-amd64-v1.14.0.gz

解压

1
gzip -d clash-linux-amd64-v1.14.0.gz

赋予可执行权限

1
chmod +x clash-linux-amd64-v1.14.0

移动到/usr/local/bin

1
sudo mv clash-linux-amd64-v1.14.0 /usr/local/bin/clash

Step 2: 获取节点配置文件

1
wget -O config.yaml https://your subscribe url
1
2
sudo mkdir /etc/clash
sudo cp config.yaml /etc/clash/

Step 3: 获取GeoIP

1
wget -O Country.mmdb https://github.com/Hackl0us/GeoIP2-CN/raw/release/Country.mmdb
1
sudo cp Country.mmdb /etc/clash/

Step 4: systemd

创建clash.service

1
vim clash.service

内容如下

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# /etc/systemd/system/clash.service
[Unit]
Description=Clash daemon, A rule-based proxy in Go.
After=network.target

[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/clash -d /etc/clash

[Install]
WantedBy=multi-user.target
1
sudo cp clash.service /etc/systemd/system

重载systemd

1
sudo systemctl daemon-reload

开机自启

1
sudo systemctl enable clash

启动clash

1
sudo systemctl start clash.service

查看状态

1
sudo systemctl status clash.service

image-20230321160757801

enjoy it!

Buy Me a Coffee ~~
hiifong 支付宝支付宝
hiifong 微信微信
0%