找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 9773|回复: 114

dnsmasq-full + nftset + nftables透明代理

 火.. [复制链接]
本帖最后由 99010 于 2024-4-5 16:59 编辑

能谷歌搜索、油管(我这里ipv6直连,8k秒开),所以老套路的dnsmasq-full + ipset + iptables用了很久。


openwrt使用fw4防火墙后,套路也要更新了,依然是dnsmasq-full这个老伙计加上nftset、nftables。


以下基于 OpenWrt 官方23.05.x。

1.安装dnsmasq-full
  1. sed -i 's#downloads.openwrt.org#mirrors.ustc.edu.cn/openwrt#g' /etc/opkg/distfeeds.conf

  2. opkg update
  3. opkg remove dnsmasq
  4. opkg install dnsmasq-full
  5. service dnsmasq restart
复制代码
2.制作gfwlist列表文件(可自行增加更多列表,注意格式),并添加到默认加载。(下面命令可全部直接复制粘贴运行)
  1. mkdir -p /etc/dnsmasq.d
  2. cat << EOF > /etc/dnsmasq.d/gfwlist.conf
  3. server=/githubusercontent.com/127.0.0.1#5353
  4. nftset=/githubusercontent.com/4#inet#fw4#gfwlist
  5. server=/github.com/127.0.0.1#5353
  6. nftset=/github.com/4#inet#fw4#gfwlist
  7. EOF
  8. uci set dhcp.@dnsmasq[-1].confdir="/etc/dnsmasq.d"
  9. uci commit
  10. service dnsmasq restart
复制代码



3.创建透明代理规则文件(注意:代理端口1080可换成你自己的)。(下面命令可全部直接复制粘贴运行)

  1. cat << EOF > /etc/nftables.d/gfwlist.nft
  2. set gfwlist {
  3. type ipv4_addr
  4. flags interval
  5. elements = { 91.108.56.0/22,
  6. 91.108.4.0/22,
  7. 91.108.8.0/22,
  8. 91.108.16.0/22,
  9. 91.108.12.0/22,
  10. 149.154.160.0/20,
  11. 91.105.192.0/23,
  12. 91.108.20.0/22,
  13. 185.76.151.0/24,
  14. }
  15. }

  16. chain gfwlist-redirect {
  17. type nat hook prerouting priority 0; policy accept;
  18. ip daddr @gfwlist ip protocol tcp redirect to :1080
  19. }
  20. EOF
  21. service firewall restart
复制代码
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.                 },
  13.                 {
  14.                 "protocol": "dokodemo-door",
  15.                 "port": 5353,
  16.                 "settings": {
  17.                         "address": "8.8.8.8",
  18.                         "port": 53,
  19.                         "network": "udp",
  20.                         "timeout": 30
  21.                         }
  22.                 }
  23.                 ],
  24.         "outbounds": [
  25.                 {
  26.                 //对应的服务端配置
  27.                 }
  28.                 ]
  29. }
复制代码


本帖子中包含更多资源

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

×
来自手机 | 显示全部楼层
谢谢老板
回复

使用道具 举报

太感谢了。找了好久了。
回复

使用道具 举报

来自手机 | 显示全部楼层
感谢分享           
回复

使用道具 举报

瞅瞅,感谢
回复

使用道具 举报

感谢分享
回复

使用道具 举报

看网页和视频 正常吗????
回复

使用道具 举报

方案不错,我也是改成了 dnsmasq-full + nftables + ipset
mark 一下,下次改成 nftset
回复

使用道具 举报

多谢楼主的分享!
回复

使用道具 举报

看看怎么样
回复

使用道具 举报

来自手机 | 显示全部楼层
这个可以满足基本需求
回复

使用道具 举报

这个试试。谢谢
回复

使用道具 举报

感谢分享
回复

使用道具 举报

感谢楼主
回复

使用道具 举报

来自手机 | 显示全部楼层
感谢分享。
回复

使用道具 举报

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

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

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

GMT+8, 2024-5-15 13:00

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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

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