找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 11415|回复: 8

用pdnsd的reject属性解决dns随机污染和cdn问题

[复制链接]
本帖最后由 dato 于 2015-2-6 23:47 编辑

dns做为最关键的一步,一直没找到好的解决方案。
最近看到网上有提到pdnsd的reject属性。上个网真得好烦,现在上网的风险太高了,随时网银不保。无良的网管已经恶心到随机性污染,唯一的特征这些污染的ip都是生活在资本主义社会的。有些网站像google可能ip实在太多了还是能通过加密通道出去的,而像twitter facebook则是永久性dns污染。那现在我们要同时兼顾dns随机污染和cdn问题,可以通过dns2socks来解决dns污染,用本地isp的dns来解决cdn问题,但怎么组合起来一直是个麻烦。
pdnsd.conf里 global有个par_queries=2参数,控制可以同时启用2个server{}查询,reject_policy=fail;则当dns查询时返回的ip命中reject列表里的ip时,则放弃当前server{}查询,选择另外一个server{}。
典型的应用如果通过dns2socks查询qq.com时,由于返回的ip为国内ip,当它命中cnip.lst时,系统不响应而是通过另外一个server{}来查询,就这么简单。
试了2天一直没成功,都要放弃了,今天才注意到原来apnic提供的ip列表根本就不完整,从这个ip列表里只能提取出27308个子网,用了这么多年apnic没想到这个列表缺失那么多。
http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest  
而从http://www.ipdeny.com获得的高达147299,HOHO,本来还很开心,哇openwrt竟然导入14万条还能运行,没想进行3个域名查询路由就没响应了,哈哈,但是有ip列表在手,方向也对了,试试好点的主机也许能解决这个问题。
刚刚不知道什么原因停止响应,在它重启后好像没什么问题。。。幸运

用来处理的脚本
#!/bin/sh
rm -rf /tmp/ip;mkdir /tmp/ip;cd /tmp/ip
wget http://www.ipdeny.com/ipblocks/data/countries/all-zones.tar.gz
tar zvfx all-zones.tar.gz
sort -V -u cn.zone>cn.lst
rm -rf cn.zone
find -name "*.zone" -exec 'cat' {} \; > uncn.tmp
sort -V -u uncn.tmp>uncn.lst

rm -rf *.zone
wget http://www.ipdeny.com/ipv6/ipadd ... v6-all-zones.tar.gz
tar zvfx ipv6-all-zones.tar.gz
sort -V -u cn.zone>cn6.lst
rm -rf cn.zone
find -name "*.zone" -exec 'cat' {} \; > uncn6.tmp
sort -V -u uncn6.tmp>uncn6.lst
rm -rf *.zone;
sed -i -e 's/$/&,/g' uncn.lst
sed -i -e 's/$/&,/g' cn.lst
sed -i -e 's/$/&,/g' uncn6.lst
sed -i -e 's/$/&,/g' cn6.lst



本帖子中包含更多资源

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

×
我的恩山、我的无线 The best wifi forum is right here.
来自手机 | 显示全部楼层
如果访问油管给个国内ip不就是呵呵了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

你是看见了这个才来发帖的吧
https://github.com/clowwindy/Chi ... suecomment-73098044
默认reject不能满足,而且性能很差.
我增加了accept功能, 和chinadns的delay功能类似
https://gist.github.com/LazyZhu/3f0ad3ec6bbd86748897

点评

L大请求防污染详细教程,https://gist.github.com/LazyZhu/3f0ad3ec6bbd86748897 只看这个,不懂啊。  详情 回复 发表于 2015-2-9 13:46
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
本帖最后由 dato 于 2015-2-9 12:33 编辑

这个世界真是太小了。。。。
目前这个方法的问题是依赖socks连接的稳定性,目前碰到alipay.com可能存在解析问题
现在整个pdnsd.conf是28325条,在家里路由全局翻,一个个人用用还是没问题的。

上传个己缩小的子网。目的尽量是简化通过域名方式进行配置,但是多多少还是不能那么完美,有时候还是得用到exclude
  1. global {
  2.        par_queries=1;
  3. }


  4. server {
  5. label="isp";
  6. ip=xxx.xxx.xxx.xxx,xxx.xxx.xxx.xxx;
  7. port=53;
  8. timeout=10;
  9. proxy_only=on;
  10. purge_cache=off;

  11. reject=1.0.0.0/24,

  12. 223.255.254.0/23;
  13. reject_policy = fail; #negate; #fail;
  14. reject_recursively=off;
  15. /*
  16. exclude=.twitter.com,
  17.           .facebook.com,
  18.           .google.com,
  19.             .googlevideo.com,
  20.           .youtube.com;
  21. */
  22. }

  23. # The following section is most appropriate if you have a fixed connection to
  24. # the Internet and an ISP which provides good DNS servers.
  25. server {
  26.         label= "myisp";
  27.         ip = 127.0.0.1;  # Put your ISP's DNS-server address(es) here.
  28.         port=5353;
  29.         proxy_only=on;     # Do not query any name servers beside your ISP's.
  30.                            # This may be necessary if you are behind some
  31.                            # kind of firewall and cannot receive replies
  32.         caching=off;                   # from outside name servers.
  33.         timeout=6;         # Server timeout; this may be much shorter
  34.                            # that the global timeout option.
  35.         uptest=if;         # Test if the network interface is active.
  36.         interface=lo;    # The name of the interface to check.
  37.         interval=10m;      # Check every 10 minutes.
  38.         purge_cache=off;   # Keep stale cache entries in case the ISP's
  39.                            # DNS servers go offline.
  40. #        edns_query=yes;    # Use EDNS for outgoing queries to allow UDP messages
  41.                            # larger than 512 bytes. May cause trouble with some
  42.                            # legacy systems.
  43. #        exclude=.thepiratebay.org,  # If your ISP censors certain names, you may
  44. #                .thepiratebay.se,   # want to exclude them here, and provide an
  45. #                .piratebay.org,            # alternative server section below that will
  46. #                .piratebay.se;            # successfully resolve the names.

  47.         reject=1.0.1.0/24,
  48.         223.255.252.0/23;

  49. reject_policy = fail; #negate; #fail;
  50. reject_recursively=off;

  51. exclude=.alipay.com,
  52.                   .sohu.com,
  53.                    .qq.com,
  54.                   .taobao.com;

  55. }
复制代码




本帖子中包含更多资源

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

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

使用道具 举报

LazyZhu 发表于 2015-2-9 03:23
你是看见了这个才来发帖的吧
https://github.com/clowwindy/ChinaDNS/issues/63#issuecomment-73098044
...

L大请求防污染详细教程,https://gist.github.com/LazyZhu/3f0ad3ec6bbd86748897 只看这个,不懂啊。

点评

http://dl.lazyzhu.com/file/openwrt-antigfw/packages/ar71xx/pdnsd_1.2.9b-par-20150209_ar71xx.ipk 参考里面的pdnsd.conf  详情 回复 发表于 2015-2-9 22:53
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

elinpr0s 发表于 2015-2-9 13:46
L大请求防污染详细教程,https://gist.github.com/LazyZhu/3f0ad3ec6bbd86748897 只看这个,不懂啊。

http://dl.lazyzhu.com/file/openw ... 20150209_ar71xx.ipk

参考里面的pdnsd.conf

点评

懂了。谢谢、  详情 回复 发表于 2015-2-10 08:39
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

LazyZhu 发表于 2015-2-9 22:53
http://dl.lazyzhu.com/file/openwrt-antigfw/packages/ar71xx/pdnsd_1.2.9b-par-20150209_ar71xx.ipk

...

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

使用道具 举报

来学习了。。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

来学习,谢谢
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

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

本版积分规则

关闭

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

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

GMT+8, 2024-4-28 15:04

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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

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