Linux——v2ray

下载v2ray 二选一

CentOS:

1
yum -y install wget && wget https://github.com/v2ray/v2ray-core/releases/download/v4.28.2/v2ray-linux-64.zip

ubuntu 或 Debian

1
apt install wget -y && https://github.com/v2ray/v2ray-core/releases/download/v4.28.2/v2ray-linux-64.zip

解压到/usr/local/v2ray/

1
mkdir /usr/local/v2ray && mv v2ray-linux-64.zip /usr/local/v2ray && cd /usr/local/v2ray/ && unzip v2ray-linux-64.zip

更改v2ray.service

1
sed -i  's#ExecStart=.*$#ExecStart=/usr/local/v2ray/v2ray -config /usr/local/v2ray/config.json#' /usr/local/v2ray/systemd/system/v2ray.service && cp -r /usr/local/v2ray/systemd/system/v2ray.service /usr/lib/systemd/system/

复制过来可以使用的config.json后 ,启动v2ray.service通过代理转流量到v2ray端口即可成功

linux终端如何把流量转到代理端口处

临时 转到http代理端口

1
2
export http_proxy=http://127.0.0.1:10809
export https_proxy=http://127.0.0.1:10809

临时 转到socks端口

1
export ALL_PROXY=socks5://127.0.0.1:10809

永久 转到代理端口将上面配置二选一放到/etc/profile 环境变量中

http

1
2
3
4
5
cat >> /etc/profile <<EOF
export http_proxy=http://127.0.0.1:10809
export https_proxy=http://127.0.0.1:10809
EOF
source /etc/profile

socks

1
2
3
4
cat >> /etc/profile <<EOF
export ALL_PROXY=socks5://127.0.0.1:10809
EOF
source /etc/profile

关于修改config.json配置中允许局域网访问和更改访问端口,具体需要修改的部分配置如下:

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
"inbounds": [
{
"tag": "socks",
"port": 10808, #socks5端口
"listen": "0.0.0.0", #允许局域网访问改成0.0.0.0,不允许局域网访问改成127.0.0.1
"protocol": "socks",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"routeOnly": false
},
"settings": {
"auth": "noauth",
"udp": true,
"allowTransparent": false
}
},
{
"tag": "http",
"port": 10809, # http端口
"listen": "0.0.0.0", #允许局域网访问改成0.0.0.0,不允许局域网访问改成127.0.0.1
"protocol": "http",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"routeOnly": false
},
"settings": {
"auth": "noauth",
"udp": true,
"allowTransparent": false
}
}
],