Git Product home page Git Product logo

v2ray-padavan's Introduction

v2ray-padavan

本文为在k2p路由器使用padavan(N56U/改华硕)固件安装配置v2ray的简单流程,相关的配置请参考官方文档。其他型号路由器理论上类似,可以参考。

为了方便小伙伴们,这里给出了一个配置样例供参考。注意替换==包含的内容为你自己的配置,路由部分使用自定义的site文件,支持gw上网及各种广告过滤,site.dat文件可以从v2ray-adlist获取最新版。

重要提示:

由于v2ray体积较大,需要自行编译路由器固件,增大storage分区的大小,可以先fork一下https://github.com/hanwckf/rt-n56u,然后根据自己的需要修改配置文件,目前使用的是自编译的K2P_DRV,如果有需要可以在我的repositories里找rt-n56u

需要修改3个文件,本文将storage分区大小调整为6mb,修改时注意进制及单位:

获取最新版本的v2ray

更新:在我的v2ray-openwrt里增加了压缩流程的相关说明,需要的话移步前去查看。release下有已经整合编译并压缩过的v2ray可以直接下载使用,直接支持读取json配置文件,不用额外转换。

下载路由器硬件对应平台的压缩包到电脑并解压。以k2p为例的话是mipsle。解压后得到v2ray单文件,文件已经使用upx压缩过,体积比官方的小,一般不超过4mb,这样才好放到路由器里。

上传软件

一共需要4个文件:v2ray、config.conf、iptables.sh、check.sh

mkdir /etc/storage/v2ray
cd /etc/storage/v2ray
# 上传v2ray相关文件到该目录下
chmod +x v2ray

透明代理(iptables.sh)

透明代理部分使用iptables实现,如果不需要可自行删减修改。

规则中局域网的ip段(192.168.1.0)和v2ray监听的端口(12345)请结合实际情况修改。

#!/bin/sh

# set iptables rules
iptables -t nat -N V2RAY
iptables -t nat -A V2RAY -d 0.0.0.0/8 -j RETURN
iptables -t nat -A V2RAY -d 127.0.0.0/8 -j RETURN
iptables -t nat -A V2RAY -d 192.168.1.0/24 -j RETURN
# From lans redirect to Dokodemo-door's local port
iptables -t nat -A V2RAY -s 192.168.1.0/24 -p tcp -j REDIRECT --to-ports 12345
iptables -t nat -A PREROUTING -p tcp -j V2RAY
iptables -t nat -A OUTPUT -p tcp -j V2RAY

点此直接下载 iptables.sh文件

启动/守护脚本(check.sh)

上次添加了守护脚本后,发现有时会出现多个进程同时存在的情况,导致cpu居高不下直至路由系统挂掉,猜测可能是脚本加在防火墙启动后调用导致,未证实。

#!/bin/sh

cd /etc/storage/v2ray

sleep 5

while true; do
    server=`ps | grep -e "v2ray[[:space:]]\|v2ray$" | grep -v grep`
    if [ ! "$server" ]; then
        ulimit -v 65536
        ./v2ray &
    fi
    sleep 60
done

点此直接下载check.sh文件

设置v2ray开机自动启动

高级设置 -> 自定义设置 -> 脚本 -> 在路由器启动后执行:

# 增加一行
/etc/storage/v2ray/check.sh &

高级设置 -> 自定义设置 -> 脚本 -> 在防火墙规则启动后执行:

# 增加一行
/etc/storage/v2ray/iptables.sh

保存软件及配置

padavan系统文件系统是构建在内存中的,重启后软件及配置会丢失,所以操作完成后,需要将v2ray及配置写入闪存。

高级设置 -> 系统管理 -> 配置管理 -> 保存内部存储到闪存: 提交

由于v2ray程序比较大,提交保存操作需要一定的时间,点过提交后请耐心等待1分钟,以确保写入成功。

如果一切顺利,重启路由器后你想要的v2ray依然在默默守护着你。Good luck!

更新记录

2019-06-07

  • 去掉pb文件相关描述

2019-03-12

  • 修改了脚本及启动方式

2019-02-11

  • 增加了守护脚本,自动重启v2ray

2018-12-10

  • 增加了客户端配置样例,方便使用

v2ray-padavan's People

Contributors

felix-fly avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.