文中有些檔案建議提前下載好,否則可能因為網路問題無法下載,建議先瀏覽全文
下載 clash 並設定
- 使用以下命令下載 Clash 最新版本
plain text
wget <https://github.com/Dreamacro/clash/releases/download/v1.18.0/clash-linux-amd64-v1.17.0.gz>
一般是換到新系統要重新設定這些東西?所以建議提前下載好存到 U 盤上或者哪裡,要不然到時候從 Github 下載只能碰運氣。
- 進入該檔案所在目錄,解壓
plain text
gunzip clash-linux-amd64-v1.18.0.gz
- 將 clash-linux-amd64-v1.18.0 檔案重新命名為 clash
plain text
mv clash-linux-amd64-v1.18.0 clash
- 在此目錄下建立資料夾(注意這裡用大寫 Clash 只是為了和 clash 區別開)
plain text
mkdir Clash
- 移動 clash 檔案到 Clash 資料夾中
plain text
mv clash ./Clash
- 進入 Clash 資料夾
plain text
cd Clash
- 下載 clash 設定檔
config.yaml(注意:這個訂閱連結是自己的,替代 [訂閱連結],如果失敗了說明訂閱連結有問題)
plain text
wget -O config.yaml [訂閱連結]
注意:如果步驟 7 失敗了也沒關係,直接跳過這一步,後面也會自動下載。也可以在網址 Country.mmdb 下載。
注意:也建議可以提前下載好,要不然到時候可能因為網路問題下載不成功
- 啟動 clash
plain text
chmod +x clash
./clash -d .
- 打開系統設定,點擊網路,找到系統代理,選擇手動
HTTP 代理:127.0.0.1:7890
HTTPS 代理:127.0.0.1:7890
SOCKS 代理:127.0.0.1:7891
即可啟動系統代理
- 訪問 http://clash.razord.top/ 。代理模式建議選為規則
HOST、連接埠、金鑰我記得不用輸入,點擊儲存和確定就可以了。可以直接在面板上切換節點
設定開機自啟動
可能有些需要管理員權限,記不清楚了。Permission denied 就在前面加 sudo
- 建立 service 檔案
plain text
touch /etc/systemd/system/clash.service
- 編輯 service 檔案
plain text
vim /etc/systemd/system/clash.service
- 編輯如下文字(vim 的使用方法請自行搜尋
plain text
Description=clash daemon
[Service]
Type=simple
User=root
ExecStart=/home/username/下载/Clash/clash -d /home/username/下载/Clash/ Restart=on-failure
[Install]
WantedBy=multi-user.target
其中 ExecStart 中位址是 clash 的具體所在位址,要根據自己 Clash 資料夾做修改
- 設定 Clash 的開機啟動項,檢查狀態,服務啟動成功之後,根據資訊設定自己客戶端的代理協定類型及連接埠(依次輸入)
plain text
sudo systemctl daemon-reload
sudo systemctl enable clash
sudo systemctl start clash
sudo systemctl status clash
後記
在使用 Arch linux 以及 Ubuntu、Zorin 時按照以上步驟都是沒有問題的。但是當我換到 Fedora 時,我發現會出現權限不足的問題。
plain text
$ sudo systemctl status clash
● clash.service - A rule based proxy in Go for shitao.
Loaded: loaded (/usr/lib/systemd/system/clash.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2019-06-18 17:27:18 CST; 4s ago
Process: 6777 ExecStart=/usr/bin/clash (code=exited, status=203/EXEC)
Main PID: 6777 (code=exited, status=203/EXEC)
Jun 18 17:27:18 localhost.localdomain systemd[1]: Started A rule based proxy in Go for shitao..
Jun 18 17:27:18 localhost.localdomain systemd[6777]: clash.service: Failed to execute command: Permission denied
Jun 18 17:27:18 localhost.localdomain systemd[6777]: clash.service: Failed at step EXEC spawning /usr/bin/clash: Permission denied
Jun 18 17:27:18 localhost.localdomain systemd[1]: clash.service: Main process exited, code=exited, status=203/EXEC
Jun 18 17:27:18 localhost.localdomain systemd[1]: clash.service: Failed with result 'exit-code'.解決方案:修改 selinux 成被動模式
plain text
sudo vim /etc/sysconfig/selinuxplain text
SELINUX=permissive