1

原生 clash linux 环境配置方法

 2 years ago
source link: https://blog.frytea.com/archives/577/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

本文首发于: https://blog.frytea.com/archives/577/

  • Ubuntu Desktop 20.04 理论适用大部分 Linux 发行版
  • Dreamacro / clash

步骤一:配置 clash 执行程序

首先从 clash 的 github 仓拉取稳定版二进制可执行文件

wget https://github.com/Dreamacro/clash/releases/download/v1.7.1/clash-linux-amd64-v1.7.1.gz
gzip -d clash-linux-amd64-v1.7.1.gz
sudo mv clash-linux-amd64-v1.7.1 /usr/bin/clash
sudo chmod +x /usr/bin/clash
clash -v
# 为 clash 添加绑定低位端口的权限,这样运行clash的时候无需root权限
sudo setcap cap_net_bind_service=+ep /usr/bin/clash

步骤二:配置 clash

此时执行 clash ,不会有任何效果,仅仅提供一个 默认端口监听:

clash

编辑 clash 配置文件 /.config/clash/config.yaml

可以将您线路提供的配置文件直接覆盖到这里,这里不涉及配置文件的编写方法。

步骤三:配置 clash 服务自启

sudo touch /etc/systemd/system/clash.service
sudo vim /etc/systemd/system/clash.service

实例服务配置如下:

[Unit]
Description=clash daemon
[Service]
Type=simple
User=<YOURNAME>
ExecStart=/usr/bin/clash -d /home/YOURNAME>/.config/clash/
Restart=on-failure
[Install]
WantedBy=multi-user.target

之后配置服务自启动

systemctl enable clash
systemctl start clash

---------------------
Author: Frytea
Title: 原生 clash linux 环境配置方法
Link: https://blog.frytea.com/archives/577/
Copyright: This work by TL-Song is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK