~~PAGEIMAGE:tools:clash:media:20231202-014128.png~~
====== Clash For Linux ======
{{template>:meta:template:pageinfo#tpl |desc=Introduce the usage of Clash For Linux.}}
===== Steps =====
- Download the latest version from [[https://github.com/Dreamacro/clash/releases|https://github.com/Dreamacro/clash/releases]].
- Unzip the download file and run sudo chmod +x clash-exe to give it execute permission.
- Run ./clash-exe -f config.yaml -d config-directory and you should see the following log. \\
* config.yaml is supported by you VPN provider or designed by you.
* config-directory is the directory where the configuration files Country.mmdb((note:>The MaxMind DB (mmdb) file format is a database format that maps IPv4 and IPv6 addresses to data records using an efficient binary search tree. Country.mmdb is a global IP database that enables the resolution and geolocation of IP information for each country. You can get more details from [[https://maxmind.github.io/MaxMind-DB/index.html]] and [[https://maxmind.github.io/GeoIP2-dotnet/doc/v2.7.0/MaxMind.GeoIP2.Model/Country.html]].)) and cache.db are stored.
\\ {{:tools:media:img:20230504-155034.png?direct&600}}
- Open Network and configure the HTTP Proxy and Socks Host to match the configuration in //config.yaml//. \\
**For example**:
* The configuration of ''HTTP'' and ''Socks'' in //config.yaml// is as follows: \\ \\
# port of HTTP
port: 7890
# port of SOCKS5
socks-port: 7891
* So the configuration of HTTP Proxy and Socks Host should be consistent with the configuration in //config.yaml//. \\ \\ {{:tools:media:img:20230504-160417.png?direct&600}} \\ {{:tools:media:img:20230504-162616.png?direct&600}}
- Open your browser and visit the specified website to check if //config.yaml// takes effect. If does, you will see a log similar to the one below. \\ \\ {{:tools:media:img:20230504-163652.png?direct&600}} \\
===== Note =====
Sometimes it is necessary to access the website __from a terminal__. The following __environmental
variables should be set__ correctly before accessing.
* ''all_proxy''
* ''http_proxy''
* ''https_proxy''
* ''ftp_proxy''
**Demo**\\
export https_proxy=socks://127.0.0.1:7891/
echo $https_proxy
socks://127.0.0.1:7891/
git clone https://github.com/giterlizzi/dokuwiki-template-bootstrap3.git
Cloning into 'dokuwiki-template-bootstrap3'...
remote: Enumerating objects: 11433, done.
remote: Counting objects: 100% (561/561), done.
remote: Compressing objects: 100% (232/232), done.
remote: Total 11433 (delta 333), reused 521 (delta 321), pack-reused 10872
Receiving objects: 100% (11433/11433), 14.42 MiB | 13.27 MiB/s, done.
Resolving deltas: 100% (6669/6669), done.
===== Autostart Clash at Boot Time =====
- Create clash.service in /etc/systemd/system/.
- Add the following to clash.service.
[Unit]
Description=Clash service
After=network.target
[Service]
ExecStart=/path/to/clash -f /path/to/config/file -d /path/to/config/directory
[Install]
WantedBy=multi-user.target
''/path/to/*'' should be modified to the path where these files are placed.
- Run sudo systemctl start clash.service ((note:>https://askubuntu.com/a/733510)) to start clash now.
- Run sudo systemctl enable clash.service ((note:>https://askubuntu.com/a/733510)) to enable starting clash automatically at boot time.
===== VPN Vendor =====
{{page>sec:tools:vpn#VPN Vendor&nofooter&noheader}}
{{template>meta:template:refnote#note}}
===== Further Reading =====
* //[[https://github.com/Dreamacro/clash/wiki#getting-started|https://github.com/Dreamacro/clash/wiki#getting-started]]//
* //[[https://github.com/Dreamacro/clash/wiki/configuration#specifying-configuration-directory|https://github.com/Dreamacro/clash/wiki/configuration#specifying-configuration-directory]]//