|
楼主 |
发表于 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瑞文件
内容如下
- #!/bin/sh /etc/rc.common
- # "new(er)" style init script
- # Look at /lib/functions/service.sh on a running system for explanations of what other SERVICE_
- # options you can use, and when you might want them.
- START=99
- SERVICE_USE_PID=1
- SERVICE_WRITE_PID=1
- SERVICE_DAEMONIZE=1
- start() {
- service_start /usr/bin/v2瑞 -config=/etc/v2瑞/config.json
- # 设置 iptables
- iptables -t nat -N v贰瑞
- iptables -t nat -A v贰瑞 -d 192.168.0.0/16 -j RETURN
- iptables -t nat -A v贰瑞 -p tcp -j REDIRECT --to-ports 1080
- iptables -t nat -A PREROUTING -p tcp -j v贰瑞
- }
- stop() {
- # 清除 iptables
- iptables -t nat -D PREROUTING -p tcp -j v贰瑞
- iptables -t nat -F v贰瑞
- iptables -t nat -X v贰瑞
- service_stop /usr/bin/v2瑞
- }
复制代码 修改/etc/init.d/v2瑞文件权限
- chmod 755 /etc/init.d/v2瑞
复制代码 设置开机启动
创建/etc/v2瑞文件夹
创建/etc/v2瑞/config.json文件
大概内容如下(仅限在4.+以上版本使用):
- {
- "inbounds":[
- { //任意门,用于透明代理
- "protocol": "dokodemo-door",
- "port": 1080,
- "listen": "0.0.0.0",
- "settings": {
- "network": "tcp, udp",
- "timeout": 30,
- "followRedirect": true
- },
- "sniffing": {
- "enabled": true,
- "destOverride": ["http", "tls"]
- },
- "tag": "in-0" //入口0标识
- },
- { //socks5,用于浏览器代理
- "port":"1081",
- "protocol":"socks",
- "settings":{
- "auth":"noauth",
- "udp":true
- },
- "sniffing": {
- "enabled": true,
- "destOverride": ["http", "tls"]
- },
- "tag": "in-1" //入口1标识
- },
- { //http代理,用于系统代理
- "port":"1082",
- "protocol":"http",
- "settings":{},
- "sniffing": {
- "enabled": true,
- "destOverride": ["http", "tls"]
- },
- "tag": "in-2" //入口2标识
- },
- { //任意门,备用dns解析
- "protocol": "dokodemo-door",
- "port": 5353,
- "settings": {
- "address": "8.8.8.8",
- "port": 53,
- "network": "udp",
- "timeout": 0
- }
- }
- ],
- "outbounds":[
- {
- "protocol":"vmess",
- "settings":{
- "vnext":[
- {
- "address":"1.1.1.1",
- "port":3333,
- "users":[
- {
- "id":"7e8bb2bc-958f-4ecd-ba03-8f1cdc4b3930",
- "alterId":32
- }
- ]
- }
- ]
- },
- "tag": "proxy" //代理标识
- },
- { //直连标识
- "sendThrough" : "0.0.0.0",
- "tag":"direct",
- "protocol":"freedom",
- "settings":{}
- },
- {
- "tag":"blocked",
- "protocol":"blackhole",
- "settings":{}
- }
- ],
- "routing":{
- "domainStrategy":"AsIs",
- "rules":[
- { //被屏蔽的域名走代理,可自行添加
- "type": "field",
- "outboundTag": "proxy",
- "domain": [
- "google.com",
- "youtube.com"
- ]
- },
- { //入口0标识的流量直连
- "type":"field",
- "inboundTag": ["in-0"],
- "outboundTag":"direct"
- },
- { //入口1标识的流量直连
- "type":"field",
- "inboundTag": ["in-1"],
- "outboundTag":"direct"
- },
- { //入口2标识的流量直连
- "type":"field",
- "inboundTag": ["in-2"],
- "outboundTag":"direct"
- }
- ]
- }
- }
复制代码
避免配置文件有错误,用命令检查一下是否正确不报错。
- v2瑞 -test -config=/etc/v2瑞/config.json
复制代码 到此配置完成,重启路由
|
|