Some files in this post are better downloaded ahead of time, or you may not be able to get them because of network issues. Skim the whole thing first.
Reference: http://jemlab.cn/?p=141
Download clash and set it up
- Download the latest Clash with:
wget <https://github.com/Dreamacro/clash/releases/download/v1.18.0/clash-linux-amd64-v1.17.0.gz>
Usually you have to redo this stuff when you switch to a new system, right? So download it in advance and keep it on a USB stick or somewhere. Otherwise downloading from GitHub later is just luck.
- Go into the directory with the file, unzip
gunzip clash-linux-amd64-v1.18.0.gz
- Rename clash-linux-amd64-v1.18.0 to clash
mv clash-linux-amd64-v1.18.0 clash
- Create a folder in this directory (uppercase Clash just to tell it apart from clash)
mkdir Clash
- Move the clash file into the Clash folder
mv clash ./Clash
- Enter the Clash folder
cd Clash
- Download the clash config
config.yaml(note: this subscription URL is yours; replace [subscription-url]; if it fails, the subscription URL is the problem)
wget -O config.yaml [subscription-url]
Note: if step 7 fails, it's fine — skip it; it'll download automatically later. You can also download Country.mmdb from that URL.
Note: better to download this in advance too, or it may fail because of the network
- Start clash
chmod +x clash
./clash -d .
- Open system settings, click Network, find system proxy, choose Manual
HTTP proxy: 127.0.0.1:7890
HTTPS proxy: 127.0.0.1:7890
SOCKS proxy: 127.0.0.1:7891
That starts the system proxy
- Visit http://clash.razord.top/. For proxy mode I suggest Rule
I don't remember having to enter HOST, port, or secret — just Save and OK. You can switch nodes right on the panel
Start on boot
Some of this may need admin. I don't remember. If you get Permission denied, put sudo in front
- Create the service file
touch /etc/systemd/system/clash.service
- Edit the service file
vim /etc/systemd/system/clash.service
- Put in the following (look up how to use vim yourself
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
The path in ExecStart is wherever clash actually lives; change it to match your Clash folder
- Enable Clash on boot, check status. Once the service is up, set your client's proxy protocol and port from that info (run these in order)
sudo systemctl daemon-reload
sudo systemctl enable clash
sudo systemctl start clash
sudo systemctl status clash
Afterword
On Arch Linux, Ubuntu, and Zorin the steps above were fine. When I switched to Fedora I hit a permission problem.
$ 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'.Fix: set selinux to permissive
sudo vim /etc/sysconfig/selinuxSELINUX=permissive