Loading... ### Linux安装Clash **这里讲无界面版本Linux如何使用Clash,并进行相关配置。** #### 1.下载Clash对应的版本 Clash的github地址:https://github.com/Dreamacro/clash 查看当前Linux系统的内核架构 ```shell uname -a ``` 如果是***aarch64***架构,则需要下载这个包:[clash-linux-armv7-v1.14.0.gz](https://github.com/Dreamacro/clash/releases/download/v1.14.0/clash-linux-armv7-v1.14.0.gz) 如果是***X86***架构,则下载这个包:[clash-linux-amd64-v3-v1.14.0.gz](https://github.com/Dreamacro/clash/releases/download/v1.14.0/clash-linux-amd64-v3-v1.14.0.gz) 具体版本可以自行选择。 #### 2.安装Clash - 解压并重命名为clash ```shell #解压 gzip -dk clash-linux-amd64-v3-v1.14.0.gz #重命名 mv clash-linux-amd64-v3-v1.14.0 clash #复制到/usr/bin cp clash /usr/bin/ ``` - 创建`/etc/clash`文件夹,需要两个文件 - Country.mmdb:全球Ip库,需要先行下载,https://cdn.jsdelivr.net/gh/Dreamacro/maxmind-geoip@release/Country.mmdb - config.yml:clash的代理配置文件 - 下载ui管理界面:https://github.com/Dreamacro/clash-dashboard/tree/gh-pages并上传到创建好的clash目录。 - 在config.yml中添加ui相关配置 ```yaml #秘钥 secret:'passwd' #外部控制访问,0.0.0.0代表内外网都可进行访问 external-controller: '0.0.0.0:9090' #前面下载的ui管理界面的地址。 external-ui: '/root/.config/clash/clash-dashboard' ``` - 添加clash.service,`vim /etc/systemd/system/clash.service`添加以下内容 ```shell [Unit] Description=clash After=network-online.target Wants=network-online.target systemd-networkd-wait-online.service [Service] Type=simple User=root Group=root DynamicUser=true ExecStart=/usr/bin/clash -d /etc/clash/ Restart=always LimitNOFILE=512000 [Install] WantedBy=multi-user.target ``` - 启动服务,添加自启动 ```shell #启动 systemctl start clash.service #添加自启动 systemctl enable clash.service #重启 systemctl restart clash.service #重启系统验证 reboot ``` - 配置系统代理 ```shell #临时方式 export http_proxy=http://127.0.0.1:7890 export https_proxy=http://127.0.0.1:7890 #永久方式,在/etc/enviroment中添加上面两句 vim /etc/environment ``` #### 3.配置代理 可以在本地访问`对应ip:9090/ui`进入远程控制界面 弹出的配置界面中分别填入ip、端口、config配置文件中的secret秘钥。 在设置中切换代理模式 #### 4.验证 ``` curl -XGet https://2023.ip138.com curl -XGet www.google.com.hk ``` © Allow specification reprint Support Appreciate the author AliPayWeChat Like 2 If you think my article is useful to you, please feel free to appreciate