下载和配置Clash

Clash 是一个Go语言开发的多平台代理客户端,用户可以使用Clash在多个平台,如Windows,Linux,Android等平台上使用代理服务。

Clash on Ubuntu

Ubuntu是Linux系列的常用系统,本文主要在Ubuntu上进行了测试,其他系统一般也会有效。

Install Package

  1. 下载Clash安装包
    clash_for_windows_pkg的GitHub页面下载对应版本,以基于X86架构的Ubuntu系统为例,在Assets中下载Clash.for.Windows-0.20.17-x64-linux.tar.gz

  2. 解压Clash安装包
    解压 *.tar.gz 文件,移动到~/目录下,命名为clash。

  3. 运行文件
    进入clash文件夹内,找到cfw文件,运行即可。

    1
    $ ./cfw

Create Desktop Shortcut

  1. 下载clash图标文件,存放至clash文件夹内。如下所示,右击选择下载即可获得。

  2. 在桌面创建文件clash.desktop,写入以下内容,注意将其中的usrname替换为自己的用户名

    1
    2
    3
    4
    5
    6
    7
    8
    [Desktop Entry]
    Version=1.0
    Type=Application
    Terminal=false
    Exec=/home/usrname/clash/cfw
    Name=Clash
    Comment=Clash for Windows
    Icon=/home/usrname/clash/clash.png
  3. 右击桌面clash图片,点击Allow Launching即可正常使用。

Clash on Windows

Install Package

clash_for_windows_pkg的GitHub页面下载对应版本。例如:在Assets中下载Clash.for.Windows.Setup.0.20.16.exe。双击安装即可。

Additional Usage Instruction

在Windows中使用终端时,默认终端不走代理,在使用如git clone或者pip install`等命令时会显示网络无法连接。
可以在Clash中开启TUN Mode后,在终端中(一般是GIT Bash)配置

1
2
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy https://127.0.0.1:7890

其中7890是Clash Port(General 面板内查看)。

Clash on Android

ClasClashForAndroid的GitHub页面下载对应版本。例如:在Assets中下载cfa-2.5.12-premium-universal-release.apk。正常安装即可。

Proxy on Local Area Network

本小节介绍如何将代理传播到局域网上的其他机器,比如局域网服务器。

Start Clash

在局域网内一台机器上启动启Clash,打开System Proxy 和 Allow LAN 按钮。

Configure proxychains

在需要使用代理的机器上,例如:一台Ubuntu服务器的用户目录下创建.proxychains,并配置proxychains.conf文件。

1
2
3
4
5
mkdir -p ~/.proxychains # 创建文件夹
cd ~/.proxychains
touch proxychains.conf # 使用touch创建文件
vim proxychains.conf # 或者 vim
gedit proxychains.conf # 或者 gedit

在创建的proxychains.conf文件中写入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# proxychains.conf  VER 3.1
#
# HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS.
#

# The option below identifies how the ProxyList is treated.
# only one option should be uncommented at time,
# otherwise the last appearing option will be accepted
#
#dynamic_chain
#
# Dynamic - Each connection will be done via chained proxies
# all proxies chained in the order as they appear in the list
# at least one proxy must be online to play in chain
# (dead proxies are skipped)
# otherwise EINTR is returned to the app
#
strict_chain
#
# Strict - Each connection will be done via chained proxies
# all proxies chained in the order as they appear in the list
# all proxies must be online to play in chain
# otherwise EINTR is returned to the app
#
#random_chain
#
# Random - Each connection will be done via random proxy
# (or proxy chain, see chain_len) from the list.
# this option is good to test your IDS :)

# Make sense only if random_chain
#chain_len = 2

# Quiet mode (no output from library)
#quiet_mode

# Proxy DNS requests - no leak for DNS data
proxy_dns

# Some timeouts in milliseconds
tcp_read_time_out 15000
tcp_connect_time_out 8000

# ProxyList format
# type host port [user pass]
# (values separated by 'tab' or 'blank')
#
#
# Examples:
#
# socks5 192.168.67.78 1080 lamer secret
# http 192.168.89.3 8080 justu hidden
# socks4 192.168.1.49 1080
# http 192.168.39.93 8080
#
#
# proxy types: http, socks4, socks5
# ( auth types supported: "basic"-http "user/pass"-socks )
#
[ProxyList]
# add proxy here ...
# meanwile
# defaults set to "tor"
socks5 ip clash-port

将最后一行的ipclash-port替换为开启Clash的机器的局域网IP和Clash Port(General面板内的第一行),使用时需要开启Allow LAN

Usage

在需要使用代理的命令前添加proxychains,例如:使用pip下载某opencv-python包:

1
proxychains pip instal opencv-python