Set up Clash Client on Your Raspberry Pi 4

There are many tutorials out there on how to set up a Raspberry Pi 4 as a Clash server. However, in my case, I’m using the Pi as a desktop replacement. After some research, I noticed that most Clash clients like Clash for Windows and ClashX do not support Raspberry Pi. However, Clash does conveniently provide release binary for Linux systems on armv7, which matches our Pi 4. So let’s get cranking!

What You Need

  • Raspberry Pi OS (or any OS based on it, like TwisterOS)
  • Internet connection (through Ethernet or WiFi)

I have tested Clash using the above setup and it worked reliably. Feel free to try it on earlier/later models of Pi or on different operating systems. Clash is versatile enough to support various system configurations. Just keep in mind that you need to look for the appropriate release binary for your system.

Download Clash

Under the latest release’s assets section, click on “clash-linux-armv7-va.b.c.gz” to download the binary, where va.b.c is is the latest version number.

Extract the downloaded binary to a convenient location. For me, it’s my home directory. Rename the binary to be “clash”, so we can refer to it more easily in the terminal.

Configure Clash

$HOME/.config/clash/config.yaml

Configure System Proxy

  1. Edit environment variables
$ sudo nano /etc/environment

Add the following three lines at the end of the file:

export http_proxy="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"
export no_proxy="localhost, 127.0.0.1"

2. Enable proxy for sudo operations

$ sudo visudo

Add the following line to the file:

Defaults    env_keep+="http_proxy https_proxy no_proxy"

3. Reboot your Pi to take effect

Run Clash!

  1. Give Clash execution permission
sudo chmod +x clash

2. Run clash

sudo clash

You should see a bunch of information messages printed on the terminal. DO NOT close the terminal because otherwise, Clash will stop running.

Manage Clash

I personally prefer the aesthetics of yacd but both work fine.

Run Clash at Startup

sudo ~/clash

The path depends on where you put Clash. Mine is located under the home directory.

Congrats!

❤️ Open Source, Web Dev, programming languages, and Hanzi 漢字