找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 6747|回复: 11

双栈网络下巧用unbound屏蔽dns解析IPV6地址

[复制链接]
发表于 2019-11-7 15:51 | 显示全部楼层 |阅读模式
本帖最后由 kob 于 2019-11-7 15:55 编辑

在IPV4/V6双栈模式下,同时有IPV4和V6地址的网站,很多时候系统会默认链接IPV6地址,导致网站不能正常打开。
在openwrt路由系统软件包里面直接搜索安装 unbound 安装luci-app-unbound luci-i18n-unbound-zh-cn unbound  libunbound
安装好了之后,该插件默认是在启动脚本/etc/init.d/unbound 初始化生成配置文件的,对了,该插件在路由配置界面的服务-递归dns设置

建议不要用uci设置,因为你设置的很多内容并不会生效,也不要在这里开启,具体使用后面介绍,现在先看配置文件
  1. server:
  2.   username: unbound
  3.   chroot: "/etc/unbound"
  4.   directory: "/etc/unbound"
  5.   pidfile: "/var/run/unbound.pid"

  6.   num-threads: 1
  7.   msg-cache-slabs: 1
  8.   rrset-cache-slabs: 1
  9.   infra-cache-slabs: 1
  10.   key-cache-slabs: 1

  11.   interface: 0.0.0.0
  12.   interface: ::0
  13.   outgoing-interface: 0.0.0.0
  14.   outgoing-interface: ::0

  15.   use-syslog: yes
  16.   verbosity: 1
  17.   statistics-interval: 0
  18.   statistics-cumulative: no
  19.   extended-statistics: no

  20.   do-ip4: yes
  21.   do-ip6: no
  22.   edns-buffer-size: 1280
  23.   msg-buffer-size: 8192
  24. <b>  port: 5335  #监听端口,建议设置为5335</b>
  25.   outgoing-port-permit: 10240-65535

  26.   harden-short-bufsize: yes
  27.   harden-large-queries: yes
  28.   harden-glue: yes
  29.   harden-below-nxdomain: no
  30.   harden-referral-path: no
  31.   use-caps-for-id: no


  32.   outgoing-range: 640
  33.   num-queries-per-thread: 320
  34.   outgoing-num-tcp: 10
  35.   incoming-num-tcp: 10
  36.   rrset-cache-size: 8192k
  37.   msg-cache-size: 4096k
  38.   key-cache-size: 4096k
  39.   neg-cache-size: 2048k
  40.   infra-cache-numhosts: 8192

  41.   module-config: "iterator"

  42.   cache-min-ttl: 120
  43.   cache-max-ttl: 36000
  44.   val-bogus-ttl: 300
  45.   infra-host-ttl: 900

  46.   hide-identity: yes
  47.   hide-version: yes

  48. <b>  private-address: ::/0  #该选项屏蔽了IPV6地址</b>
  49.   private-address: 100.64.0.0/10
  50.   private-address: 169.254.0.0/16
  51.   private-address: 172.16.0.0/12
  52.   private-address: 192.168.0.0/16
  53.   private-address: fc00::/7
  54.   private-address: fe80::/10

  55.   access-control: 192.168.13.1/24 allow
  56.   access-control: 100.109.99.239/32 allow
  57.   access-control: 10.179.39.72/17 allow
  58.   access-control: 117.69.148.102/32 allow
  59.   access-control: 36.57.90.217/32 allow
  60.   access-control: 127.0.0.0/8 allow
  61.   access-control: ::1/128 allow
  62.   access-control: fe80::/10 allow

  63.   include: /etc/unbound/unbound_srv.conf

  64.   include: /etc/unbound/adb_list.*

  65.   local-zone: lan. static
  66.   domain-insecure: lan
  67.   private-domain: lan

  68.   local-zone: openwrt. static
  69.   domain-insecure: openwrt
  70.   private-domain: openwrt

  71.   local-zone: local. static
  72.   domain-insecure: local
  73.   private-domain: local

  74. <b>  local-data: "openwrt. 120 IN A 192.168.13.1"   #本地路由信息,自行修改
  75.   local-data-ptr: "192.168.13.1 120 openwrt"   </b><b>#本地路由信息</b><b>,自行修改</b>
  76.   # note link address fe80::6adb:54ff:fe44:20ff


  77. forward-zone:
  78.   name: "/etc/resolv.dnsmasq.conf."  <b>#上游dns服务器</b>
  79.   forward-addr: 202.102.213.68
  80.   forward-addr: 61.132.163.68
  81.   forward-addr: 202.102.213.68
  82.   forward-addr: 61.132.163.68
  83.   forward-addr: 120.210.253.105
  84.   forward-addr: 120.210.253.106


  85. include: /etc/unbound/unbound_ext.conf

复制代码
将附件下载后,自行修改了上传到/etc/unbound目录覆盖unbound.conf    resolv.dnsmasq.conf文件上传到/etc目录下
然后在系统-启动项-本地启动脚本添加
  1. # Put your custom commands here that should be executed once
  2. # the system init finished. By default this file does nothing.
  3. sleep 30
  4. killall pdnsd

  5. /usr/sbin/unbound -d -c /etc/unbound/unbound.conf
  6. exit 0
复制代码
该插件就随系统启动,此时还没有完,需要进一步设置dnsmasq
进 网络-DHCP/DNS菜单

将你需要屏蔽AAAA解析的域名填入,格式如下
  1. /netflix.com/127.0.0.1#5335
复制代码
此时,加入进去的域名解析时,dnsmasq会交给ubound去执行。但如果你的电脑等客户端dns服务器为运营商分配或者自定义的时候,还是不会生效,所以在lan的dhcp设置里面不要自定义任何dns,默认dhcp分配路由ip为dns服务器(包括IPV4和IPV6)
但有时候这样一条一条添加也比较麻烦,可以结合gfwlist的方式,如果你路由装有S*s*R插件的话,就将dns设置为如下方式

不要用插件默认的pdnsd,这样所有g*fwlist清单内的域名都将会交给unbound来解析

本帖子中包含更多资源

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

×
我的恩山、我的无线 The best wifi forum is right here.
发表于 2019-11-7 18:15 | 显示全部楼层
直接把WAN6接口 协议: DHCPv6 客户端這裏關閉的話,還需要安裝?

点评

kob
目的是既要用到IPV6(如移动宽带V4是内网IP,就需要保留V6用到V6的公网IP实现远程访问等),但又不想netflix,google等网站因为解析到ipv地址而不能打开或者无法正常使用  详情 回复 发表于 2019-11-8 10:15
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2019-11-8 10:15 | 显示全部楼层
ager1111 发表于 2019-11-7 18:15
直接把WAN6接口 协议: DHCPv6 客户端這裏關閉的話,還需要安裝?

目的是既要用到IPV6(如移动宽带V4是内网IP,就需要保留V6用到V6的公网IP实现远程访问等),但又不想netflix,google等网站因为解析到ipv地址而不能打开或者无法正常使用
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2019-11-8 10:31 | 显示全部楼层
应该很多人有这个困扰,一旦使用 ipv6 地址网关透明代理直接失效,我的目的其实是在IPV6环境下,还不能影响透明网关代理使用的问题
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-11-8 11:47 来自手机 | 显示全部楼层
优秀 学习一下 unbound
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-11-8 16:33 | 显示全部楼层
目前来说还是负优化,我直接在sysctl里关了。有公网v4的不是很在意。

点评

kob
有公网V4,直接无视  详情 回复 发表于 2019-11-12 11:31
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2019-11-12 11:31 | 显示全部楼层
imyoona 发表于 2019-11-8 16:33
目前来说还是负优化,我直接在sysctl里关了。有公网v4的不是很在意。

有公网V4,直接无视
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-12-27 09:37 | 显示全部楼层
本帖最后由 净量 于 2019-12-27 14:17 编辑

最近正好遇到ipv6与透明代理共存的问题。还是舍不得ipv6的公网地址。
谢谢楼主



试了下,我在lede下配合v贰瑞,,没有成功,不知道怎么弄

点评

kob
我推荐你用smartdns  详情 回复 发表于 2020-1-3 16:14
来自微站
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2020-1-3 16:14 | 显示全部楼层
本帖最后由 kob 于 2020-1-3 16:26 编辑
净量 发表于 2019-12-27 09:37
最近正好遇到ipv6与透明代理共存的问题。还是舍不得ipv6的公网地址。
谢谢楼主

我推荐你用smartdns在
域名地址指定特定域名的IP地址

address /www.netflix.com/#6

点评

大佬,我这样设置并重启服务了,但是返回的还是IPv6地址,请问您知道可能是什么原因吗,或者能贴一下你smartdns第二服务器(墙外那个)的配置吗?  详情 回复 发表于 2020-12-23 07:29
对的,配合功夫网列表很好用  详情 回复 发表于 2020-1-21 13:54
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-1-21 13:54 来自手机 | 显示全部楼层
kob 发表于 2020-1-3 16:14
我推荐你用smartdns在
域名地址指定特定域名的IP地址


对的,配合功夫网列表很好用
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-12-23 07:29 | 显示全部楼层
kob 发表于 2020-1-3 16:14
我推荐你用smartdns在
域名地址指定特定域名的IP地址

大佬,我这样设置并重启服务了,但是返回的还是IPv6地址,请问您知道可能是什么原因吗,或者能贴一下你smartdns第二服务器(墙外那个)的配置吗?

点评

kob
勾选Force AAAA SOA  详情 回复 发表于 2020-12-27 19:25
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2020-12-27 19:25 | 显示全部楼层
loverwtf 发表于 2020-12-23 07:29
大佬,我这样设置并重启服务了,但是返回的还是IPv6地址,请问您知道可能是什么原因吗,或者能贴一下你sm ...

勾选Force AAAA SOA
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-3-29 03:51

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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

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