系统环境

  • OS:kali linux 2023.03
  • Kernel:6.4.0-kali3-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.4.11-1kali1 (2023-08-21) x86_64 GNU/Linux

v2ray 部署

安装 v2ray

1.从 v2ray 项目 地址下载 v4.28.2 版本的压缩文件到 /usr/local/src/ 目录下:

1
sudo wget -O /usr/local/src/v2ray-linux-64.zip https://github.com/v2ray/v2ray-core/releases/download/v4.28.2/v2ray-linux-64.zip

2.将下载好的压缩包解压到 /usr/local/src/v2ray 目录:

1
sudo unzip /usr/local/src/v2ray-linux-64.zip -d /usr/local/src/v2ray

3.将解压处理的 v2ray 移动到 /usr/local/ 目录下:

1
sudo mv /usr/local/src/v2ray /usr/local/v2ray

4.在 /usr/local/v2ray 目录下创建 bin 目录,并将 v2ray 移动到 bin 目录下:

1
2
3
sudo mkdir /usr/local/v2ray/bin 
sudo mv /usr/local/v2ray/v2ray* /usr/local/v2ray/bin
sudo mv /usr/local/v2ray/geo* /usr/local/v2ray/bin

5.在 /usr/local/v2ray 目录下创建 etc 目录,并在该目录下创建配置文件 config.json ,配置内容如下:

1
sudo mkdir /usr/local/v2ray/etc

/usr/local/v2ray/etc/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
{
"inbounds": [
{
"port": 1080,
"protocol": "socks",
"domainOverride": ["tls", "http"],
"settings": {
"auth": "noauth"
}
}
],
"outbounds": [
{
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "domain.com",
"port": 443,
"users": [
{
"id": "dcd1111-0237-442b-953f-9ccf84d85678",
"alterId": 0
}
]
}
]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"wsSettings": {
"path": "/"
}
}
}
]
}

6.在 /lib/systemd/system/ 目录下创建 v2ray.service 文件,内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[Unit]
Description=V2Ray Service
Documentation=https://www.v2fly.org/
After=network.target nss-lookup.target

[Service]
User=nobody
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/usr/local/v2ray/bin/v2ray -config /usr/local/v2ray/etc/config.json
Restart=on-failure
RestartPreventExitStatus=23

[Install]
WantedBy=multi-user.target

7.执行脚本重载命令加载启动脚本,并将服务设置为开机自启动:

1
sudo systemctl daemon-reload && sudo systemctl enable --now v2ray.service

参考: