OpenWrt安装v2rayA教程,一看就会

简介

OpenWrt这个很多用软路由的都晓得,我们这期讲如何在OpenWrt下安装v2raya。

 

教程

v2rayA 自建软件源安装

添加 v2rayA 使用密钥

wget https://osdn.net/projects/v2raya/storage/openwrt/v2raya.pub -O /etc/opkg/keys/94cc2a834fb0aa03

导入 v2rayA feed

echo "src/gz v2raya https://osdn.net/projects/v2raya/storage/openwrt/$(. /etc/openwrt_release && echo "$DISTRIB_ARCH")" | tee -a "/etc/opkg/customfeeds.conf"

# Japan mirror
# echo "src/gz v2raya https://ftp.jaist.ac.jp/pub/sourceforge.jp/storage/g/v/v2/v2raya/openwrt/$(. /etc/openwrt_release && echo "$DISTRIB_ARCH")" | tee -a "/etc/opkg/customfeeds.conf"
# US mirror
# echo "src/gz v2raya https://mirrors.gigenet.com/OSDN/storage/g/v/v2/v2raya/openwrt/$(. /etc/openwrt_release && echo "$DISTRIB_ARCH")" | tee -a "/etc/opkg/customfeeds.conf"

更新一下

opkg update

安装 v2rayA 及其依赖项

opkg install v2raya

# Check your firewall implementation
# Install the following packages for the nftables-based firewall4 (command -v fw4)
# Generally speaking, install them on OpenWrt 22.03 and later
opkg install kmod-nft-tproxy
# Install the following packages for the iptables-based firewall3 (command -v fw3)
# Generally speaking, install them on OpenWrt 21.02 and earlier
opkg install iptables-mod-conntrack-extra \
  iptables-mod-extra \
  iptables-mod-filter \
  iptables-mod-tproxy \
  kmod-ipt-nat6

# Choose a core you'd like to use, v2ray or Xray
# If you have both installed, the latter is preferred by default
#
# Note from maintainer: due to broken tproxy support in v2ray, recommend using Xray instead
opkg install xray-core
# opkg install v2ray-core

# Optional
# opkg install v2fly-geoip v2fly-geosite

通过LuCI接口配置(仅适用于OpenWrt 21.02及更高版本)

opkg install luci-app-v2raya

访问web页面

访问http://<your_router_ip>/cgi-bin/luci/admin/services/v2raya并完成设置。

 

通过 OpenWrt 官方软件源安装

使用 OpenWrt 21.02 或更高版本的用户可以直接从软件源安装。

opkg update
opkg install v2raya

 

通过手动安装v2raya

首先安装软件包 unzip 与 wget,然后从 Github Releases 下载 V2Ray 核心并将其保存到 /usr/bin/,最后赋予二进制文件可执行权限

opkg update; opkg install unzip wget-ssl
wget https://github.com/v2fly/v2ray-core/releases/download/v4.40.1/v2ray-linux-64.zip
unzip -d v2ray-core v2ray-linux-64.zip
cp v2ray-core/v2ray v2ray-core/v2ctl /usr/bin
chmod +x /usr/bin/v2ray; chmod +x /usr/bin/v2ctl

安装依赖包与内核模块,OpenWrt 22.03 或更新版本:

opkg update
opkg install \
    ca-bundle \
    ip-full \
    kmod-nft-tproxy

安装依赖包与内核模块,OpenWrt 21.02 或更早版本:

opkg update
opkg install \
    ca-bundle \
    ip-full \
    iptables-mod-conntrack-extra \
    iptables-mod-extra \
    iptables-mod-filter \
    iptables-mod-tproxy \
    kmod-ipt-nat6

从 Github Releases 下载最新版本对应处理器架构的二进制文件,然后移动到 /usr/bin/ 并赋予可执行权限

wget https://github.com/v2rayA/v2rayA/releases/download/v2.0.5/v2raya_linux_x64_2.0.5 -O v2raya
mv v2raya /usr/bin/v2raya && chmod +x /usr/bin/v2raya

下载配置文件和服务文件

wget https://raw.githubusercontent.com/openwrt/packages/master/net/v2raya/files/v2raya.config -O /etc/config/v2raya
wget https://raw.githubusercontent.com/openwrt/packages/master/net/v2raya/files/v2raya.init -O /etc/init.d/v2raya
chmod +x /etc/init.d/v2raya

启用并运行 v2rayA

uci set v2raya.config.enabled='1'
uci commit v2raya
/etc/init.d/v2raya enable
/etc/init.d/v2raya start
THE END