找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 43851|回复: 152

openwrt官方固件使用v2瑞的手动配置教程

 火.. [复制链接]
发表于 2019-8-27 23:00 | 显示全部楼层 |阅读模式
本帖最后由 99010 于 2019-8-28 00:13 编辑

dnsmasq-full、ipset、gfwlist模式


安装必要的组件
  1. opkg update
  2. opkg remove dnsmasq
  3. rm -rf /etc/config/dhcp
  4. opkg install dnsmasq-full
  5. opkg install ipset iptables-mod-nat-extra
复制代码
修改/etc/firewall.user,添加如下
  1. ipset -N gfw iphash
  2. iptables -t nat -A PREROUTING -p tcp -m set --match-set gfw dst -j REDIRECT --to-port 1080
复制代码
修改/etc/dnsmasq.conf,添加如下
  1. conf-dir=/etc/dnsmasq.d
复制代码
创建/etc/dnsmasq.d/gfw.conf文件
  1. vi /etc/dnsmasq.d/gfw.conf
复制代码
内容如下(可自行添加或者找网上分享的gfwlist列表,注意一下格式)
  1. server=/google.com/127.0.0.1#5353
  2. ipset=/google.com/gfw
  3. server=/youtube.com/127.0.0.1#5353
  4. ipset=/youtube.com/gfw
  5. server=/twitter.com/127.0.0.1#5353
  6. ipset=/twitter.com/gfw
复制代码
下载路由器对应架构的v2瑞执行文件
https://github.com/v2瑞/v2瑞-core/releases
或者
https://github.com/felix-fly/v2瑞-openwrt/releases
解压后把v2ctl、v2瑞上传到/usr/bin目录,记得把v2ctl、v2瑞权限修改为0755。


创建/etc/init.d/v2瑞文件
  1. vi /etc/init.d/v2瑞
复制代码
内容如下
  1. #!/bin/sh /etc/rc.common
  2. # "new(er)" style init script
  3. # Look at /lib/functions/service.sh on a running system for explanations of what other SERVICE_
  4. # options you can use, and when you might want them.

  5. START=99

  6. SERVICE_USE_PID=1
  7. SERVICE_WRITE_PID=1
  8. SERVICE_DAEMONIZE=1

  9. start() {
  10.         service_start /usr/bin/v2瑞 -config=/etc/v2瑞/config.json
  11. }

  12. stop() {
  13.         service_stop /usr/bin/v2瑞
  14. }
复制代码
修改/etc/init.d/v2瑞文件权限
  1. chmod 755 /etc/init.d/v2瑞
复制代码
设置开机启动
  1. /etc/init.d/v2瑞 enable
复制代码


创建/etc/v2瑞文件夹
  1. mkdir /etc/v2瑞
复制代码
创建/etc/v2瑞/config.json文件
  1. vi /etc/v2瑞/config.json
复制代码
大概内容如下(仅限在4.+以上版本使用):
  1. {
  2.         "inbounds":[
  3.                 {  //任意门,用于透明代理
  4.                 "protocol": "dokodemo-door",
  5.                 "port": 1080,
  6.                 "listen": "0.0.0.0",
  7.                 "settings": {
  8.                         "network": "tcp, udp",
  9.                         "timeout": 0,
  10.                         "followRedirect": true
  11.                         }
  12.                 },
  13.                 { //任意门,备用dns解析
  14.                 "protocol": "dokodemo-door",
  15.                 "port": 5353,
  16.                 "settings": {
  17.                         "address": "8.8.8.8",
  18.                         "port": 53,
  19.                         "network": "udp",
  20.                         "timeout": 0
  21.                         }
  22.                 }
  23.                         ],
  24.         "outbounds":[
  25.                 {
  26.                 "protocol":"vmess",
  27.                 "settings":{
  28.                         "vnext":[
  29.                                 {
  30.                                 "address":"1.1.1.1",
  31.                                 "port":3333,
  32.                                 "users":[
  33.                                         {
  34.                                         "id":"7e8bb2bc-958f-4ecd-ba03-8f1cdc4b3930",
  35.                                         "alterId":32
  36.                                         }
  37.                                                 ]
  38.                                 }
  39.                                         ]
  40.                                 },
  41.                 "streamSettings":{
  42.                         "network":"kcp",
  43.                         "security":"none",
  44.                         "kcpSettings":{}
  45.                         }
  46.                 }
  47.                         ]
  48. }
复制代码
避免配置文件有错误,用命令检查一下是否正确不报错。
  1. v2瑞 -test -config=/etc/v2瑞/config.json
复制代码
到此配置完成,重启路由
  1. reboot
复制代码
gfwlist列表

ipset模式v2瑞的配置文件,解压后按照对应目录上传。



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

评分

参与人数 4恩山币 +1 收起 理由
h*** + 1 楼上几位对路由器的理解有些狭隘啊,openwrt有x86版本,软路由上一劳永逸搞
yufe*** + 2 70周年国庆,祝愿祖国繁荣昌盛!
win*** -1 楼上根本不理解路由器的透明代理的意义,你家的电视想看youtube,客人来看也想
loog*** -1 闲的奶子疼,在路由器安装这个,直接安装客户端

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.
 楼主| 发表于 2019-8-27 23:00 | 显示全部楼层
本帖最后由 99010 于 2019-12-27 15:22 编辑

有些路由器没有足够的空间安装dnsmasq-full、ipset等组件,可以使用下面的方法。
缺点是消耗比较多的cpu使用率以及连接服务端的速度略慢。

下载路由器对应架构的v2瑞执行文件
https://github.com/felix-fly/v2瑞-openwrt/releases
解压后把v2瑞上传到/usr/bin/目录,记得把v2瑞权限修改为0755。


创建/etc/init.d/v2瑞文件
  1. vi /etc/init.d/v2瑞
复制代码
内容如下
  1. #!/bin/sh /etc/rc.common
  2. # "new(er)" style init script
  3. # Look at /lib/functions/service.sh on a running system for explanations of what other SERVICE_
  4. # options you can use, and when you might want them.

  5. START=99

  6. SERVICE_USE_PID=1
  7. SERVICE_WRITE_PID=1
  8. SERVICE_DAEMONIZE=1

  9. start() {
  10.         service_start /usr/bin/v2瑞 -config=/etc/v2瑞/config.json
  11.         # 设置 iptables
  12.         iptables -t nat -N v贰瑞
  13.         iptables -t nat -A v贰瑞 -d 192.168.0.0/16 -j RETURN
  14.         iptables -t nat -A v贰瑞 -p tcp -j REDIRECT --to-ports 1080
  15.         iptables -t nat -A PREROUTING -p tcp -j v贰瑞
  16. }

  17. stop() {
  18.         # 清除 iptables
  19.         iptables -t nat -D PREROUTING -p tcp -j v贰瑞
  20.         iptables -t nat -F v贰瑞
  21.         iptables -t nat -X v贰瑞
  22.         service_stop /usr/bin/v2瑞
  23. }
复制代码
修改/etc/init.d/v2瑞文件权限
  1. chmod 755 /etc/init.d/v2瑞
复制代码
设置开机启动
  1. /etc/init.d/v2瑞 enable
复制代码

创建/etc/v2瑞文件夹
  1. mkdir /etc/v2瑞
复制代码
创建/etc/v2瑞/config.json文件
  1. vi /etc/v2瑞/config.json
复制代码

大概内容如下(仅限在4.+以上版本使用):
  1. {
  2.         "inbounds":[
  3.                 {  //任意门,用于透明代理
  4.                 "protocol": "dokodemo-door",
  5.                 "port": 1080,
  6.                 "listen": "0.0.0.0",
  7.                 "settings": {
  8.                         "network": "tcp, udp",
  9.                         "timeout": 30,
  10.                         "followRedirect": true
  11.                         },
  12.                 "sniffing": {
  13.                         "enabled": true,
  14.                         "destOverride": ["http", "tls"]
  15.                         },
  16.                 "tag": "in-0"  //入口0标识
  17.                 },
  18.                 {  //socks5,用于浏览器代理
  19.                 "port":"1081",
  20.                 "protocol":"socks",
  21.                 "settings":{
  22.                         "auth":"noauth",
  23.                         "udp":true
  24.                                 },
  25.                 "sniffing": {
  26.                         "enabled": true,
  27.                         "destOverride": ["http", "tls"]
  28.                         },
  29.                 "tag": "in-1"  //入口1标识
  30.                 },
  31.                 { //http代理,用于系统代理
  32.                 "port":"1082",
  33.                 "protocol":"http",
  34.                 "settings":{},
  35.                 "sniffing": {
  36.                         "enabled": true,
  37.                         "destOverride": ["http", "tls"]
  38.                         },
  39.                 "tag": "in-2"  //入口2标识
  40.                 },
  41.                 { //任意门,备用dns解析
  42.                 "protocol": "dokodemo-door",
  43.                 "port": 5353,
  44.                 "settings": {
  45.                         "address": "8.8.8.8",
  46.                         "port": 53,
  47.                         "network": "udp",
  48.                         "timeout": 0
  49.                         }
  50.                 }
  51.                         ],
  52.         "outbounds":[
  53.                 {
  54.                 "protocol":"vmess",
  55.                 "settings":{
  56.                         "vnext":[
  57.                                 {
  58.                                 "address":"1.1.1.1",
  59.                                 "port":3333,
  60.                                 "users":[
  61.                                         {
  62.                                         "id":"7e8bb2bc-958f-4ecd-ba03-8f1cdc4b3930",
  63.                                         "alterId":32
  64.                                         }
  65.                                                 ]
  66.                                 }
  67.                                         ]
  68.                                 },
  69.                 "tag": "proxy"  //代理标识
  70.                 },
  71.                 {  //直连标识
  72.                 "sendThrough" : "0.0.0.0",
  73.                 "tag":"direct",
  74.                 "protocol":"freedom",
  75.                 "settings":{}
  76.                 },
  77.                 {
  78.                 "tag":"blocked",
  79.                 "protocol":"blackhole",
  80.                 "settings":{}
  81.                 }
  82.                         ],
  83.         "routing":{
  84.                 "domainStrategy":"AsIs",
  85.                 "rules":[
  86.                         { //被屏蔽的域名走代理,可自行添加
  87.                         "type": "field",
  88.                         "outboundTag": "proxy",
  89.                         "domain": [
  90.                         "google.com",
  91.                         "youtube.com"
  92.                                 ]
  93.                         },
  94.                         { //入口0标识的流量直连
  95.                         "type":"field",
  96.                         "inboundTag": ["in-0"],
  97.                         "outboundTag":"direct"
  98.                         },
  99.                         { //入口1标识的流量直连
  100.                         "type":"field",
  101.                         "inboundTag": ["in-1"],
  102.                         "outboundTag":"direct"
  103.                         },
  104.                         { //入口2标识的流量直连
  105.                         "type":"field",
  106.                         "inboundTag": ["in-2"],
  107.                         "outboundTag":"direct"
  108.                         }
  109.                         ]
  110.                 }
  111. }
复制代码


避免配置文件有错误,用命令检查一下是否正确不报错。
  1. v2瑞 -test -config=/etc/v2瑞/config.json
复制代码
到此配置完成,重启路由
  1. reboot
复制代码





我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-8-27 23:08 来自手机 | 显示全部楼层
厉害得,谢谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-8-27 23:24 | 显示全部楼层
感觉真的好复杂
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-8-27 23:25 | 显示全部楼层
感谢楼主分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-8-28 01:29 | 显示全部楼层
谢谢分享!!!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-8-28 09:05 | 显示全部楼层
感谢分享!!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-8-28 09:51 | 显示全部楼层
感谢楼主分享~~~
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-8-28 13:47 | 显示全部楼层
谢谢分享!!谢谢分享!!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-8-28 14:09 | 显示全部楼层
受教受教我的网络贴了几段稳定好多
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-8-29 20:55 | 显示全部楼层
楼主辛苦了,谢谢发布!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-8-29 22:44 | 显示全部楼层
学习一下,谢谢奉献分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-8-29 22:50 | 显示全部楼层
厉害得,谢谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-8-30 14:59 | 显示全部楼层
大神真是NB
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-8-30 17:32 | 显示全部楼层
谢谢楼主分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-25 13:57

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表