Hello World

吞风吻雨葬落日 欺山赶海踏雪径

0%

Linux Mint install v2ray

Project V is a set of network tools that helps you to build your own computer network. It secures your network connections and thus protects your privacy.

下载

https://github.com/v2fly/v2ray-core/releases

安装

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
#!/bin/sh

# 检查是否为 root 用户
if [ "$EUID" -ne 0 ]; then
echo "错误:请以 root 权限运行此脚本。"
exit 1
fi

# 检查是否存在 v2ray-linux-64.zip 文件
ZIP_FILE="v2ray-linux-64.zip"
if [ ! -f "$ZIP_FILE" ]; then
echo "错误:当前目录不存在文件 $ZIP_FILE"
exit 1
fi

# 解压文件到临时目录 v2ray
echo "正在解压 $ZIP_FILE ..."
unzip "$ZIP_FILE" -d v2ray
cd v2ray || { echo "进入目录失败"; exit 1; }

# 移动二进制文件到 /usr/local/bin/
echo "正在安装二进制文件..."
mv v2ray /usr/local/bin/v2ray

# 创建配置文件目录并移动配置文件
echo "正在配置 V2Ray 配置文件..."
mkdir -p /usr/local/etc/v2ray/
mv config.json /usr/local/etc/v2ray/

# 创建日志目录并创建日志文件
echo "正在配置日志文件..."
mkdir -p /var/log/v2ray/
touch /var/log/v2ray/access.log /var/log/v2ray/error.log
chmod 666 /var/log/v2ray/access.log
chmod 666 /var/log/v2ray/error.log

# 创建 geo 数据目录并移动相关文件
echo "正在安装 Geo 数据文件..."
mkdir -p /usr/local/share/v2ray/
mv geoip.dat /usr/local/share/v2ray/
mv geosite.dat /usr/local/share/v2ray/
mv geoip-only-cn-private.dat /usr/local/share/v2ray/

# 安装 systemd 服务文件
echo "正在安装 systemd 服务..."
mkdir -p /etc/systemd/system/
mv ./systemd/system/v2ray.service /etc/systemd/system/

echo "✅ 安装完成!"

测试配置文件

1
v2ray test /usr/local/etc/v2ray/config.json

启用服务

1
2
systemctl enable v2ray --now
systemctl status v2ray

配置

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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
{
"log": {
"access": "",
"error": "",
"loglevel": "warning"
},
"inbounds": [
{
"tag": "socks",
"port": 7890,
"listen": "0.0.0.0",
"protocol": "socks",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"routeOnly": false
},
"settings": {
"auth": "noauth",
"udp": true,
"allowTransparent": false
}
},
{
"tag": "http",
"port": 7891,
"listen": "0.0.0.0",
"protocol": "http",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"routeOnly": false
},
"settings": {
"auth": "noauth",
"udp": true,
"allowTransparent": false
}
}
],
"outbounds": [
{
"tag": "proxy",
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "xxx.xxx.xxx.xxx",
"port": 443,
"users": [
{
"id": "xxxx-xxx-xxx-xxx-uuid",
"alterId": 0,
"email": "t@t.tt",
"security": "auto",
"encryption": "none"
}
]
}
]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"tlsSettings": {
"allowInsecure": false,
"serverName": "xxx.xxx.xxx",
"show": false
},
"wsSettings": {
"path": "/xxx",
"headers": {
"Host": "xxx.xxx.xxx"
}
}
},
"mux": {
"enabled": false,
"concurrency": -1
}
},
{
"tag": "direct",
"protocol": "freedom",
"settings": {}
},
{
"tag": "block",
"protocol": "blackhole",
"settings": {
"response": {
"type": "http"
}
}
}
],
"dns": {
"servers": [
"8.8.8.8",
"1.1.1.1"
]
},
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"inboundTag": [
"api"
],
"outboundTag": "api"
},
{
"type": "field",
"outboundTag": "direct",
"domain": [
"domain:example-example.com",
"domain:example-example2.com"
]
},
{
"type": "field",
"outboundTag": "block",
"domain": [
"geosite:category-ads-all"
]
},
{
"type": "field",
"outboundTag": "direct",
"domain": [
"geosite:cn"
]
},
{
"type": "field",
"outboundTag": "direct",
"ip": [
"geoip:private",
"geoip:cn"
]
}
]
}
}