引用

https://github.com/Dreamacro/clash 【clash】
https://github.com/Dreamacro/clash/wiki/Running-Clash-as-a-service#systemd 【作为服务运行】
http://clash.razord.top/#/connections 【clash-dashboard远程可视控制台 官方搭建】

流程

  1. 下载clash发行版本【选择Linux amd64】
  2. 解压缩并重命名为clash【方便使用】
gzip -d ./clash-linux-amd64-你的版本.gz
mv clash-linux-amd64-你的版本 clash
  1. 赋权,使用当前目录作为配置文件夹执行 【会开始下载config.yaml,Country.mmdb,两个个文件,大约6M】
chmod u+x clash
./clash -d .
  1. 编辑配置文件
配置文件大部分机场会直接提供,可以去机场安装教程中找到,然后替换config.yaml即可,不要修改文件编码
【
	注意!如果需要用到 远程控制台 则需要填写config.yaml的中的口令及API
	# Clash 的 RESTful API
	external-controller: '0.0.0.0:9090'

	# RESTful API 的口令
	secret: 'xxxx' 
】
如果没有可以参考官方文档的介绍
https://lancellc.gitbook.io/clash/clash-config-file/an-example-configuration-file

完成编辑后,可再次通过
./clash -d .
尝试运行程序【ctrl+c】
  1. 开启系统代理【可选】
根据config.ymal的设置,在系统中设置系统代理

contos 图形界面可开启 网络管理器 通过图形方式设置
systemctl start NetworkManager

命令行环境下 自行搜索 hhhhh

image.png
6. 运行并通过clash-dashboard切换节点

./clash -d . 运行后,在自己电脑上访问
http://clash.razord.top/#/connections
填写目的ip,端口及config.yaml中设置的口令切换节点

7.通过systemd已服务的方式运行clash
官方教程
将 Clash 二进制文件复制到 /usr/local/bin 并将配置文件复制到 /etc/clash【目的是统一文件夹位置,方便后面操作,命令如下】

$ cp clash /usr/local/bin
$ cp config.yaml /etc/clash/
$ cp Country.mmdb /etc/clash/

在以下位置创建文件clash.service

/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
After that you're supposed to reload systemd:

刷新配置文件

systemctl daemon-reload

开机自启

systemctl enable clash

运行

systemctl start clash

停止

systemctl stop clash

Q.E.D.


在线