10年世界杯冠军_梅西2018年世界杯 - kefulq.com

云服务器Linux+Clash科学上网

美国篮球世界杯 2025-09-29 11:01:39

1. 下载Clash for Linux到Linux主机上

获取Clash文件

方法1,下载网址Releases · Dreamacro/clash (github.com),选择自己的系统的包,然后上传到服务器上。

方法2,使用wget命令.

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

然后解压得到binaries,重命名一下。

gzip -d clash-linux-amd64-v3-v1.13.0.gz

mv clash-linux-amd64-v1.10.0 clash

添加执行权限。

chmod +x clash

2. 添加配置文件

创建配置文件目录,Clash会自动读取这个文件里的配置。

mkdir ~/.config/clash

接下来向~/.config/clash添加config.yaml和Country.mmdb。前者是节点配置文件,后者是GeoLite2 data created by MaxMind。

添加config.yaml。

从Clash for Windows里可以找到自己机场的配置文件,右键Show in folder,把这个文件(有可能是.yml后缀,二者格式完全相同)重命名为config.yaml,并上传至~/.config/clash。

添加Country.mmdb。

首次运行clash,Clash会自行下载,下载速度虽然慢,但是一般不会出错的下载完成。

手动下载Releases · Dreamacro/maxmind-geoip (github.com),然后上传至~/.config/clash。

3. 运行

在刚才有clash的目录下运行,不出意外的话应该显示:

clash

INFO[0000] Start initial compatible provider xx

INFO[0000] Mixed(http+socks) proxy listening at: 127.0.0.1:7890

INFO[0000] RESTful API listening at: [::]:9090

除此之外,还要开启系统代理:

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

测试运行:

curl https://www.google.com

连通输出示例:此时可以curl -L https://www.google.com跟踪跳转

302 Moved

302 Moved

The document has moved

here.

未连通输出示例:

curl: (35) Encountered end of file

4. (可选)以服务方式运行与快捷启动/关闭代理

以服务方式运行

移动相关文件到系统推荐的位置。

#在Clash当前文件的目录下

mv ~/.config/clash /etc

mv clash /usr/local/bin/clash

创建服务

vim /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

设置开机自启动

systemctl enable clash

运行Clash

systemctl start clash

查看状态与输出,若和之前输出相同,则无错。

设置快捷开启系统代理与关闭系统代理

在~/.bashrc,中填入以下内容。

function proxy_off() {

unset http_proxy

unset https_proxy

unset no_proxy

echo -e "Proxy Off"

}

function proxy_on(){

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

export https_proxy=$http_proxy

export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"

echo -e "Proxy On"

}

然后source使其生效。

source ~/.bashrc

这样之后,可以直接输入proxy_on和proxy_off,快捷开启和关闭。

5. 参考

在 Linux 上使用 Clash 作代理 | Verne in GitHub (einverne.github.io)

在 Linux 中使用 Clash | CodeSwift (iswiftai.com)