V2Ray 配置指南:
神一样的工具们
1.
System→Administration→设置好路由器SSH端口:1000
System→System→设置Timezone:Asia/Shanghai
(步骤3安装zoneinfo-asia是为了看log没有时差)
2.
SSH连接路由器,安装UPnP。
ssh -p 1000 [email protected]
opkg update
3.
安装插件
opkg install bash curl unzip luci-app-upnp libustream-openssl zoneinfo-asia (想装DOH才需要 https-dns-proxy luci-app-https-dns-proxy )
如果服务器在局域网,要修改option rfc1918_filter
vi /etc/config/uhttpd
option rfc1918_filter 1
修改成
option rfc1918_filter 0
4.
安装V2ray,运行脚本
wget https://install.direct/go.sh
bash go.sh(以后升级也运行这句)
5.
添加V2ray服务
vi /etc/init.d/v2ray
写入以下内容:
#!/bin/sh /etc/rc.common
#
# Copyright (C) 2017 Ian Li <[email protected]>
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
START=90
USE_PROCD=1
start_service() {
mkdir /var/log/v2ray > /dev/null 2>&1
procd_open_instance
procd_set_param respawn
procd_set_param command /usr/bin/v2ray/v2ray -config /etc/v2ray/config.json
procd_set_param file /etc/v2ray/config.json
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param pidfile /var/run/v2ray.pid
procd_close_instance
}
vi的编辑指令如下
i 开始编辑
esc 退出编辑
:q 退出vi
:q! 不存档退出vi
:w 将编辑的文字保存到文件中
:x 保存退出
6.
修改配置文件
(我这里的配置不适合所有人,请自行理解修改)
vi /etc/v2ray/config.json
可以本地改完config文件后上传
scp -P1000 -r ~/Downloads/config.json [email protected]:/etc/v2ray
需要UUID可以去网站生成
{
"log":
{
"loglevel": "debug",
"access": "/var/log/v2ray/access.log",
"loglevel": "warning",
"error": "/var/log/v2ray/error.log"
},
"inbounds": [
{
"port": 443,
"protocol": "vmess",
"settings": {
"clients": [
{
"email": "1", //用户名,在log里可以查看
"id": "UUID1", //不同用户用不同的UUID区分
"alterId": 8
},
{
"email": "2",
"id": "UUID2",
"alterId": 8
},
{
"email": "3",
"id": "UUID3",
"alterId": 8
}
]
},
"streamSettings": {
"network":"tcp",
"security": "tls",
"tlsSettings": {
"serverName": "example.com", //写服务器域名
"allowInsecure": false,
"certificates": [
{
"certificateFile": "/etc/v2ray/cert.pem", //TLS证书路径
"keyFile": "/etc/v2ray/privkey.pem" //TLS私钥路径
}
]
}
}
}
],
"routing": {
"domainStrategy": "IPOnDemand",
"rules": [
{
"type": "field",
"outboundTag": "block",
"domain": [
"geosite:category-ads", //屏蔽广告
"geosite:category-porn", //屏蔽https网站
"regexp:\\.*porn.*\\.*$", //屏蔽http网站
"regexp:.*porn.*\\.*$", //屏蔽http网站
]
}
]
},
"outbounds": [
{
"protocol": "freedom",
"settings": {},
"tag": "connect"
},
{
"protocol": "blackhole",
"settings": {},
"tag": "block"
}
]
}
我这里是下载NAS上DDNS的证书,解压缩到Downloads文件夹,把chain.pem内容复制到cert.pem,然后上传证书。
scp -P1000 -r ~/Downloads/cert.pem ~/Downloads/privkey.pem [email protected]:/etc/v2ray
配置文件检测:
/usr/bin/v2ray/v2ray -test -config /etc/v2ray/config.json
7. 设置自动开机启动服务,启动服务
chmod +x /etc/init.d/v2ray
/etc/init.d/v2ray enable
service v2ray start
以后修改config.json后要执行
service v2ray restart
查看服务状态
service v2ray status
scp -P1000 -r ~/Downloads/dlc.dat [email protected]:/usr/bin/v2ray/geosite.dat
9. 下载log文件
scp -P1000 -r [email protected]:/var/log/v2ray ~/Downloads
为了看log清净,删除invalid user行
sed '/invalid user/d' ~/Downloads/v2ray/access.log > ~/Downloads/access.log
sed '/invalid user/d' ~/Downloads/v2ray/error.log > ~/Downloads/error.log
另外附上一键检查更新及升级所有Openwrt Package的指令
opkg list_installed | sed 's/ - .*//' | sed 's/^/opkg upgrade /'
opkg list-upgradable | awk -F ' - ' '{print $1}' | xargs opkg upgrade
没有评论:
发表评论