Skip to content

Linux 科学上网教程

封面图

操作步骤:

1. 创建mihomo 目录

shell
// 在linux 对应目录下创建mihomo 目录
mkdir mihomo

2. 进入到mihomo 目录下并下载 clash

shell
//我下载的是v1.18.10版本的
cd mihomo
wget https://github.com/MetaCubeX/mihomo/releases/download/v1.18.10/mihomo-linux-amd64-compatible-go120-v1.18.10.gz

3. 将文件移动到mihomo 目录下并更名

shell
// 将文件移动到mihomo 目录下并更名为clash-linux.gz
mv mihomo-linux-amd64-compatible-go120-v1.18.10.gz clash-linux.gz

4. 解压到当前文件夹并添加可执行权限

shell
gzip -f clash-linux.gz -d
chmod +x clash-linux

5. 初始化执行 clash

shell
./clash-linux

6. 等几分钟,然后按 Ctrl+c 退出clash

初始化执行 clash 会默认在 mihomo目录下生成配置文件和全球IP地址库:config.yaml、Country.mmdb、GeoSite.dat

如果GeoSite.dat 、Country.mmdb 下载失败可手动下载并添加到mihomo 目录下,下载命令如下:

shell
curl -s -L -o geosite.dat "https://github.com/v2fly/domain-list-community/raw/release/dlc.dat"

wget https://github.com/Dreamacro/maxmind-geoip/releases/latest/download/Country.mmdb

7. 下载 clash 配置文件

shell
// 根据订阅地址下载对应的clash 配置文件(更新订阅节点)
wget -U "Mozilla/6.0" -O mihomo/config.yaml  你的Clash订阅链接地址

8. 再次启动clash

shell
./clash-linux

9. 查看clash 使用的端口

shell
netstat -tulnp | grep clash-linux

10. 测试命令

shell
// 如果能返回google 首页的源码,则代表成功
curl -L --proxy socks5h://127.0.0.1:9981 https://www.google.com

11. 设置端口代理

shell
//此处得到的是步骤9里面查询到的端口,默认为9981
export http_proxy="http://127.0.0.1:port"
export https_proxy="http://127.0.0.1:port"

12. 如果需要取消代理(可选)

shell
unset http_proxy
unset https_proxy

PS: 如果上述的文件找不到可以从此处下载该文章中需要的所有文件(包括了Country.mmdb、GeoSite.dat、clash-linux.gz)

参考原文 https://fanqiang.gitbook.io/fanqiang/linux

Powered by VitePress