V2ray配置(转载)


连接VPS服务器

1
ssh root@服务器ip地址

Windows用户可以使用专门的连接工具,如Xshell、Mobaxterm

快速搭建v2ray

  1. 首先安装curl命令行下载工具
1
2
sudo apt update
sudo apt install curl
  1. 然后安装V2ray一键安装脚本
1
2
3
bash <(curl -sL https://raw.githubusercontent.com/hijkpw/scripts/master/goV2.sh)
或者备用地址
bash <(curl -sL https://raw.githubusercontent.com/hxq2291895932/V2ray/master/goV2.sh?token=ALWXYSXC2OTKNIU24RNCA23BVB656)

安装完成后会出现PORTUUID信息,表示安装完成了,记住端口号和UUID。V2ray的配置信息可使用下列命令查看。

1
cat /etc/v2ray/config.json

开放端口号

首先安装防火墙管理的工具ufw

1
sudo apt install ufw

开放相应的端口号

1
ufw allow 1234 # 这里的1234改成上述记住的端口号

开启v2ray

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
## 配置开机时启动服务和开启服务
systemctl enable v2ray
systemctl start v2ray

## 如果要关闭和停止
systemctl stop v2ray
# 重启服务
systemctl restart v2ray
# 开机时停止服务
systemctl disable v2ray
# 查看服务是否开机启动
systemctl is-enabled v2ray
# 查看已启动的服务列表
systemctl list-unit-files|grep enabled
# 查看启动失败的服务列表
systemctl --failed

客户端配置

  1. Windows可以使用v2rayN,安卓端可以使用Kitsunebi

​ 在客户端中需要填写的信息主要包括:地址端口UUIDAlterId,加密方式默认auto、传输协议默认**tcp ** 即可。

  1. 此外Windows和Linux还可安装v2ray-core的客户端。

    地址为https://github.com/v2ray/v2ray-core/releases,安装完后找到相应的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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{
"log": {
"loglevel": "info"
},
"inbounds": [
{
"port": 1080,
"protocol": "socks",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
},
"settings": {
"udp": true
}
},
{
"port": 8080,
"protocol": "http",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [
{
"tag": "proxy-vmess",
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "你的服务器ip地址",
"port": 你的v2ray端口,
"users": [
{
"id": "你的uuid",
"alterId": 4
}
]
}
]
}
},
{
"tag": "direct",
"settings": {},
"protocol": "freedom"
}
],
"dns": {
"server": [
"8.8.8.8",
"1.1.1.1"
]
},

"routing": {
"domainStrategy": "IPOnDemand",
"rules": [
{
"type": "field",
"outboundTag": "proxy-vmess"
},
{
"type": "field",
"domain": [
"geosite:cn"
],
"outboundTag": "direct"
},
{
"type": "field",
"outboundTag": "direct",
"ip": [
"geoip:cn",
"geoip:private"
]
}
]
}
}

v2ray相关

官网:https://www.v2ray.com/

GitHub:https://github.com/v2ray/v2ray-core