Linux下安装Clash客户端

https://github.com/MetaCubeX/mihomo/releases

安装并配置

gzip -d mihomo-linux-amd64-v1.19.9.gz
mv mihomo-linux-amd64-v1.19.9 mihomo
chmod 755 mihomo

执行mihomo并生成配置文件

./mihomo -d conf

如果报下面的错误:

This program can only be run on AMD64 processors with v3 microarchitecture support.

则说明,你的cpu不支持v3的指令集,如果你使用的是kvm虚拟机,则需要你把cpu的类型变更为【x86-64-v3】后重启虚拟机。

使用你自己的配置文件替换掉生成的conf/config.yaml文件

cd conf
 mv 1740387954658.yml config.yaml

重新执行mihomo即可

./mihomo -d conf

配置成服务

# vim /lib/systemd/system/clash.service

[Unit]
Description=Clash proxy service
After=network-online.target

[Service]
Type=simple
WorkingDirectory=/opt/mihomo-1.19.9
ExecStart=/opt/mihomo-1.19.9/mihomo -d conf
ExecReload=/bin/kill -HUP $MAINPID
User=clash
Group=nogroup
Restart=always
NoNewPrivileges=yes

# 增强保护
ProtectSystem=strict
ProtectHome=yes
NoNewPrivileges=yes
PrivateTmp=yes
ReadWritePaths=/opt/mihomo-1.19.9/conf

[Install]
WantedBy=multi-user.target
systemctl enable clash
systemctl start clash

设置http代理

export HTTP_PROXY='http://192.168.3.184.:7890'
export HTTPS_PROXY='http://192.168.3.184:7890'

测试

curl https://www.google.com/