Share this post on:

准备工作

clash-core : https://github.com/Dreamacro/clash/releases

clash节点yml文件,自行网上查找

终端科学上网

解压clash-core文件:

gunzip clash-linux-amd64-v1.12.0.gz

给文件权限:

chmod +x clash-linux-amd64-v1.12.0

在opt目录里建立一个名称clash目录:

sudo mkdir /opt/clash

重命名clash和yml文件

mv clash-linux-amd64-v1.12.0 clash
mv ywJYD4.yml config.yml

移动clash-core文件到建立的clash目录里:

sudo mv clash /opt/clash

移动clash节点yaml文件到建立的clash目录里:

sudo mv config.yml /opt/clash

进入clash目录:

cd /opt/clash

可选方法一:

运行clash并指定yml文件:

./clash -f config.yml

建立clash服务:

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

插入以下内容并保存退出

[Unit]

Description=clash-core

[Service]

Type=simple

ExecStart=/opt/clash/clash -f /opt/clash/config.yml

重新加载配置:

systemctl daemon-reload

启动clash:

systemctl start clash

查看clash运行状态:

systemctl status clash

检查能否科学上网(现在应该是还不行的)

curl -i google.com

手动设置终端科学上网:(现在应该是可以的了)

export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890

设置一个终端科学上网的变量:

sudo vim ~/.bashrc

插入以下内容并保存退出

alias proxy="export http_proxy=http://127.0.0.1:7890;export https_proxy=http://127.0.0.1:7890;"

alias unproxy="unset http_proxy;unset https_proxy;"

编译下变量文件:

source ~/.bashrc

运行unproxy检查科学上网状态:(运行后不能科学上网了)

unproxy

运行proxy检查科学上网状态:(运行后可以科学上网)

proxy

浏览器科学上网

image-20230509183057032

image-20230509183154064

image-20230509183436712

这样设置之后浏览器就可以科学上网了

UI界面(可选)

在/opt/clash中建立一个名称ui目录:

sudo mkdir ui

进入ui目录:

cd ui

下载ui文件:

sudo wget https://github.com/Dreamacro/clash-dashboard/archive/refs/heads/gh-pages.zip

解压ui文件:

sudo unzip gh-pages.zip

删除压缩包文件:

sudo rm -rf gh-pages.zip

把目录里的文件移动到ui目录:

sudo mv clash-dashboard-gh-pages/* .

返回clash目录:

cd ..

打开配置文件:

sudo vim config.yml

插入以下内容并保存退出

external-ui: /opt/clash/ui

重启clash:

systemctl restart clash

打开浏览器,输入网址:ubuntu系统IP:9090\ui

ubuntu系统ip可用ifconfig查看

最后效果如下:

image-20230509184656619

每次启动

先启动服务:

systemctl start clash

然后:

proxy

查看clash运行状态:

systemctl status clash
Share this post on:

Leave a Comment

您的邮箱地址不会被公开。 必填项已用 * 标注