armbina安装V2raya方法与配置指南

V2Ray

方法一:通过软件源安装

v2rayA/v2rayA】项目的官方文档提供了很多种安装方法的指导,直接添加软件源。

# 添加公钥
wget -qO - https://apt.v2raya.org/key/public-key.asc | sudo tee /etc/apt/keyrings/v2raya.asc

# 添加软件源
echo "deb [signed-by=/etc/apt/keyrings/v2raya.asc] https://apt.v2raya.org/ v2raya main" | sudo tee /etc/apt/sources.list.d/v2raya.list

# 更新 & 安装
sudo apt update && sudo apt install v2ray v2raya -y

# 启动 v2rayA
`sudo systemctl start v2raya.service`

# 设置开机自动启动
sudo systemctl enable v2raya.service

# 启动 & 添加启动项
sudo systemctl enable --now v2raya.service

启动v2raya以后,打开浏览器,访问http://host-ip:2017即可访问v2raya的web ui。

v2rayA 配置:点击右上角的 设置,我照抄的官网上的推荐配置。

  • 透明代理/系统代理: 启用: 大陆白名单模式
  • 透明代理/系统代理实现方式: redirect
  • 规则端口的分流模式: 大陆白名单模式
  • 防止DNS污染: 仅防止DNS劫持(快速)
  • 特殊模式: supervisor
  • TCPFastOpen: 保持系统默认
  • 嗅探: Http + TLS + Quic
  • 多路复用: 启用 8
  • 自动更新订阅: 服务端启动时更新订阅
  • 解析订阅链接/更新时优先使用: 跟随透明代理/系统代理

梯子配置信息,全选后点左上角的 PING可以测速延时,然后选中会用到的节点,点击**左上角的 启用`**即可。

到这里全部v2raya的配置就结束了。

如果局域网内有其他机器需要走代理,比如debian,只需要在.bashrc中添加代理配置:

export http_proxy="http://192.168.1.9:20172"
export https_proxy="http://192.168.1.9:20172"

如果是windows,在设置——网络——代理中进行配置。

img

这里要留意,如果要走v2raya中配置的分流规则,端口号需要指向20172(默认的端口号)。

img


方法二:手动安装 deb 包

从 Release 下载 v2rayA 的 deb 包 后可以使用 Gdebi、QApt 等图形化工具来安装,也可以使用命令行:

sudo apt install /path/download/installer_debian_xxx_vxxx.deb ### 自行替换 deb 包所在的实际路径

V2Ray / Xray 的 deb 包可以在 APT 软件源中 找到。

# v2ray_5.37.0_arm64.deb
# v2raya_2.2.7.1_arm64.deb
# 安装时先安装v2ray,然后安装 v2raya。

使用命令安装:

# 安装 v2ray
B860:~:# apt install "/mnt/v2ray_5.37.0_arm64.deb"
注意,选中 'v2ray' 而非 '/mnt/v2ray_5.37.0_arm64.deb'
将要安装:
v2ray

摘要:
升级:0,安装:1,卸载:0,不升级:43
下载大小:0 B / 16.8 MB
所需的空间:56.3 MB / 25.0 GB 可用

获取:1 /mnt/v2ray_5.37.0_arm64.deb v2ray arm64 5.37.0 [16.8 MB]
正在选中未选择的软件包 v2ray。
(正在读取数据库 ... 系统当前共安装有 42166 个文件和目录。)
准备解压 /mnt/v2ray_5.37.0_arm64.deb ...
正在解压 v2ray (5.37.0) ...
正在设置 v2ray (5.37.0) ...
# 安装 v2raya
B860:~:# apt install "/mnt/v2raya_2.2.7.1_arm64.deb"
注意,选中 'v2raya' 而非 '/mnt/v2raya_2.2.7.1_arm64.deb'
将要安装:
v2raya

摘要:
升级:0,安装:1,卸载:0,不升级:43
下载大小:0 B / 12.7 MB
所需的空间:30.5 MB / 24.9 GB 可用

获取:1 /mnt/v2raya_2.2.7.1_arm64.deb v2raya arm64 2.2.7.1 [12.7 MB]
正在选中未选择的软件包 v2raya。
(正在读取数据库 ... 系统当前共安装有 42175 个文件和目录。)
准备解压 /mnt/v2raya_2.2.7.1_arm64.deb ...
正在解压 v2raya (2.2.7.1) ...
正在设置 v2raya (2.2.7.1) ...
******************************
* Completed! *
******************************
B860:~:#

分流规则

如果选择gfw模式,需要用到gfwlist.dat资源文件,记得点击更新,如果是root用户,gfwlist.dat文件的存放路径在"/root/.local/share/v2ray/LoyalsoldierSite.dat"

如果是用大陆白名单模式,记得更新geosite.dat和geoip.dat文件,这俩文件的存放路径在/usr/share/v2ray

在v2raya中我没有找到自动更新这俩文件的入口,所以做好写个脚本自动更新,更新来源可以查看【Loyalsoldier/v2ray-rules-dat】这个项目。官方项目

启动 v2rayA / 设置 v2rayA 自动启动

从 1.5 版开始将不再默认为用户启动 v2rayA 及设置开机自动。

  • 启动 v2rayA

    sudo systemctl start v2raya.service
  • 设置开机自动启动,这个最好是需要的时候就起动

    sudo systemctl enable v2raya.service

设置 v2rayA

通过端口: http://localhost:2017 访问 UI 界面按提示进行节点导入并启动节点,一次可以选取多个节点并启动。

通过右上角的设置可以进行设置

设置完成后终端输入: curl https://www.google.com 看是否有信息返回。

如果是用大陆白名单模式,记得更新geosite.dat和geoip.dat文件,这俩文件的存放路径在/usr/share/v2ray。下载地址1下载地址二

关闭v2raya服务 :sudo systemctl stop v2raya

重置密码:sudo v2raya --reset-password

启动服务:sudo systemctl start v2raya

关闭开机自启动项

  • 查看项的当前服务状态:sudo systemctl status v2rayav2raya为例
  • 如果服务已经启用,可以使用命令禁用它:sudo systemctl disable v2raya
  • 如果服务没有启用:sudo systemctl enable v2raya
  • 现在此项服务将不再开机自启动了,如果要启用:sudo systemctl start v2raya

错误解决

failed to connect: failed to connect: unsupported shadowsocks encryption method: chacha20-ietf

选择节点时不要选择【协议】有带ietf的节点,要不就会出现上面的这个问题。

自动更新geosite.dat

#!/bin/bash
echo "开始更新geosite.dat文件!"
echo "开启v2raya服务"
sudo systemctl start v2raya
sleep 60
sudo systemctl status v2raya

# "/absh/sh/"
## 如果drpy_ver不存在就创建一个,并_ver值为空,存在就读取version文件里的数据给_ver
if [ -f "/absh/sh/geosite_ver" ]; then
#读取本地版本号
local_ver=$(cat "/absh/sh/geosite_ver")
echo "本地版本:$local_ver"
else
local_ver=""
fi
echo $local_ver

# cat /root/site.json | jq -r '.assets[] | select(.name == "geosite.dat") | .browser_download_url '

## 获取所有的latest版本信息中的 .[0] 表示获取 JSON 数组的第一个元素
## curl -s https://api.github.com/repos/OWNER/REPO/releases | jq -r '.[0].tag_name'

## "获取最新一个 Latest版本信息中的 “tag_name” 赋值给 LATEST_TAG "
# LATEST_TAG=$(curl -s https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest | jq -r '.tag_name')


API_URL="https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest"
RESPONSE=$(curl -s "$API_URL" )
# 检查 API 请求是否成功
if [ $? -ne 0 ]; then
echo "错误: 无法连接到 GitHub API"
echo "停止v2raya服务"
sudo systemctl stop v2raya
exit 1
fi

#提取 tag_name所在行; head -n 1 如果tag_name 有多行的话 只取第一行
LATEST_TAG=$(echo "$RESPONSE" | jq -r ".tag_name" | head -n 1)
echo $LATEST_TAG
#判断变量是否为空
if [ "$LATEST_TAG" = "null" ] || [ -z "$LATEST_TAG" ]; then
echo "没有获取到LATEST_TAG版本!"
echo "停止v2raya服务"
sudo systemctl stop v2raya
# 退出脚本
exit 1
fi

echo "判断是否需要更新"
if [ "$local_ver" = "$LATEST_TAG" ]; then
echo "已经是最新 Latest-release 版本!"
echo "停止v2raya服务"
sudo systemctl stop v2raya
# 退出脚本
exit 1
fi

echo "发现新 Latest-release 版本 $LATEST_TAG"
echo "准备更新geosite.dat和geoip.dat"
# 方法1: 直接从 assets 中查找 geosite.dat 文件
DOWNLOAD_geosite_URL=$(echo "$RESPONSE" | jq -r '.assets[] | select(.name=="geosite.dat" ) | .browser_download_url')
DOWNLOAD_geoip_URL=$(echo "$RESPONSE" | jq -r '.assets[] | select(.name=="geoip.dat") | .browser_download_url')
echo "geosite.dat下载链接:$DOWNLOAD_geosite_URL"
echo "geoip.dat下载链接:$DOWNLOAD_geoip_URL"

# 如果方法1找不到,使用方法2: 使用通用的最新版本下载链接
if [ -z "$DOWNLOAD_geosite_URL" ] || [ "$DOWNLOAD_geosite_URL" = "null" ]; then
echo "未在 assets 中找到 geosite.dat,geoip.dat 尝试使用通用下载链接..."
DOWNLOAD_geosite_URL="https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat"
DOWNLOAD_geoip_URL="https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat"
fi

# 下载文件-O 指定保存文件名; -c 断点传输
# wget_result=$(wget -NS "$DOWNLOAD_geosite_URL" -O /absh/sh/geosite.dat 2>&1|grep "HTTP/"| awk '{print $2}')

wget -c -O /absh/sh/geosite.dat "$DOWNLOAD_geosite_URL"
wget -c -O /absh/sh/geoip.dat "$DOWNLOAD_geoip_URL"
# 判断下载是否成功 [ $? -eq 0 ] 特殊变量 $? 表示上一条命令的退出状态,0 表示成功,非0 表示上一条失败。
echo "上一个命令的退出状态码是: $?"
if [ $? != 0 ]; then
echo "下载失败!"
echo "停止v2raya服务"
sudo systemctl stop v2raya
exit 1
fi

# "/absh/sh/geoip.dat"
# "/usr/share/v2ray/"
# "/root/.local/share/v2ray/LoyalsoldierSite.dat"
echo "拷贝、移动文件到其它目录"
cp /absh/sh/geosite.dat /root/.local/share/v2ray/LoyalsoldierSite.dat
mv /absh/sh/geoip.dat /usr/share/v2ray/geoip.dat && mv /absh/sh/geosite.dat /usr/share/v2ray/geosite.dat

# 修改 /absh/sh/geosite_ver文件 tag版本标志
echo "$LATEST_TAG" > "/absh/sh/geosite_ver"

echo "停止v2raya服务"
sudo systemctl stop v2raya

## 出现的问题 file busy(文本文件忙),发生此错误是因为当前文件已被占用,
## 因此只要找出占用该文件的进程并杀死就可以了。
## zsh: 文本文件忙: ./drpy_update.sh
## B860:~:# fuser drpy_update.sh
## /root/drpy_update.sh: 15550
## B860:~:# kill -9 15550

参考文章

  1. 总结目前国内加速拉取 docker 镜像的几种方法
  2. v2rayA用户文档

自动安装v2ray

root@uefi-x86:~# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 22562 100 22562 0 0 22577 0 --:--:-- --:--:-- --:--:-- 22562
info: Installing V2Ray v5.40.0 for x86_64
Downloading V2Ray archive: https://github.com/v2fly/v2ray-core/releases/download/v5.40.0/v2ray-linux-64.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:36 --:--:-- 0
100 16.6M 100 16.6M 0 0 22009 0 0:13:14 0:13:14 --:--:-- 492k
Downloading verification file for V2Ray archive: https://github.com/v2fly/v2ray-core/releases/download/v5.40.0/v2ray-linux-64.zip.dgst
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
python3-pkg-resources
使用'apt autoremove'来卸载它(它们)。
建议安装:
zip
下列【新】软件包将被安装:
unzip
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 94 个软件包未被升级。
需要下载 173 kB 的归档。
解压缩后会消耗 396 kB 的额外空间。
获取:1 https://mirrors.tuna.tsinghua.edu.cn/debian trixie/main amd64 unzip amd64 6.0-29 [173 kB]
已下载 173 kB,耗时 0秒 (493 kB/s)
正在选中未选择的软件包 unzip。
(正在读取数据库 ... 系统当前共安装有 36405 个文件和目录。)
准备解压 .../unzip_6.0-29_amd64.deb ...
正在解压 unzip (6.0-29) ...
正在设置 unzip (6.0-29) ...
正在处理用于 man-db (2.11.2-2) 的触发器 ...
info: unzip is installed.
info: Extract the V2Ray package to /tmp/tmp.Udpmk1TRYS and prepare it for installation.
info: Systemd service files have been installed successfully!
warning: The following are the actual parameters for the v2ray service startup.
warning: Please make sure the configuration file path is correctly set.
# /etc/systemd/system/v2ray.service
[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/bin/v2ray run -config /usr/local/etc/v2ray/config.json
Restart=on-failure
RestartPreventExitStatus=23

[Install]
WantedBy=multi-user.target

# /etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf
# In case you have a good reason to do so, duplicate this file in the same directory and make your customizes there.
# Or all changes you made will be lost! # Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
[Service]
ExecStart=
ExecStart=/usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json

installed: /usr/local/bin/v2ray
installed: /usr/local/share/v2ray/geoip.dat
installed: /usr/local/share/v2ray/geosite.dat
installed: /usr/local/etc/v2ray/config.json
installed: /var/log/v2ray/
installed: /var/log/v2ray/access.log
installed: /var/log/v2ray/error.log
installed: /etc/systemd/system/v2ray.service
installed: /etc/systemd/system/v2ray@.service
removed: /tmp/tmp.Udpmk1TRYS
info: V2Ray v5.40.0 is installed.
You may need to execute a command to remove dependent software: apt purge curl unzip
Please execute the command: systemctl enable v2ray; systemctl start v2ray
root@uefi-x86:~#

V2Ray安装配置指南

单独安装方法:V2Ray安装配置指南