免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 8353 | 回复: 8
打印 上一主题 下一主题

[DNS] 如何设置dns只对指定的域名转发? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-07-06 10:22 |只看该作者 |倒序浏览
我想dns只对baidu.com及子域名进行递归查询,请问如何设置,下面是我的设置文件!

操作系统:CentOS 5.5
BIND版本:
[root@localhost ~]# rpm -qa bind*
bind-9.3.6-4.P1.el5_4.2
bind-chroot-9.3.6-4.P1.el5_4.2
bind-libs-9.3.6-4.P1.el5_4.2
bind-devel-9.3.6-4.P1.el5_4.2
bind-sdb-9.3.6-4.P1.el5_4.2
bind-libbind-devel-9.3.6-4.P1.el5_4.2
bind-utils-9.3.6-4.P1.el5_4.2

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
named.conf配置如下:

options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";

allow-query { any; };
allow-query-cache { none; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
match-clients { any; };
match-destinations { any; };
recursion yes;
include "/etc/named.rfc1912.zones";
};

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
named.rfc1912.zones配置内容如下:

zone "." IN {
type hint;
file "named.ca";
};

zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};

zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};

zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};


//百度域名
zone "baidu.com" IN {
type forward;
forwarders { 202.106.0.20; };
};

论坛徽章:
0
2 [报告]
发表于 2010-07-06 18:23 |只看该作者

论坛徽章:
0
3 [报告]
发表于 2010-07-07 10:06 |只看该作者
本帖最后由 chaoy 于 2010-07-07 10:07 编辑

谢谢llzqq,那篇文章我之前看到了。
我想要达到的目的是不解析所有zone中指定之外的域名,但是bind9好像默认解析所有域名到cache,我关闭缓存查询后,forward zone也不起作用了,很苦恼!我把根域删掉后bind9照样能解析到外网域名,不知道如何关闭bind9的默认解析所有域名功能。

论坛徽章:
0
4 [报告]
发表于 2010-07-07 11:14 |只看该作者
本帖最后由 chaoy 于 2010-07-07 11:16 编辑

看来只能将就实现这个功能了,本来不想设置一个空的转发地址,觉得这样效率不好,没办法了,将就了。有好的方法请告诉我啊!

在options添加
  1. forwarders { 127.0.0.1; }; //一个不存在的地址也行
  2. forward only;
复制代码
这样区中的转发功能才能生效。
具体配置如下:
  1. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. named.conf配置如下:

  3. options {
  4. listen-on port 53 { any; };
  5. listen-on-v6 port 53 { ::1; };
  6. directory "/var/named";
  7. dump-file "/var/named/data/cache_dump.db";
  8. statistics-file "/var/named/data/named_stats.txt";
  9. memstatistics-file "/var/named/data/named_mem_stats.txt";

  10. allow-query { any; };
  11. allow-query-cache { any; };
  12. forwarders { 127.0.0.1; };
  13. forward only;
  14. };
  15. logging {
  16. channel default_debug {
  17. file "data/named.run";
  18. severity dynamic;
  19. };
  20. };
  21. view localhost_resolver {
  22. match-clients { any; };
  23. match-destinations { any; };
  24. recursion yes;
  25. include "/etc/named.rfc1912.zones";
  26. };

  27. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. named.rfc1912.zones配置内容如下:

  29. zone "." IN {
  30. type hint;
  31. file "named.ca";
  32. };

  33. zone "localdomain" IN {
  34. type master;
  35. file "localdomain.zone";
  36. allow-update { none; };
  37. };

  38. zone "localhost" IN {
  39. type master;
  40. file "localhost.zone";
  41. allow-update { none; };
  42. };

  43. zone "0.0.127.in-addr.arpa" IN {
  44. type master;
  45. file "named.local";
  46. allow-update { none; };
  47. };


  48. //百度域名
  49. zone "baidu.com" IN {
  50. type forward;
  51. forwarders { 202.106.0.20; };
  52. };

复制代码

论坛徽章:
0
5 [报告]
发表于 2010-07-07 13:03 |只看该作者
在named.conf中关闭递归查询

论坛徽章:
0
6 [报告]
发表于 2010-07-07 13:42 |只看该作者
回复 5# llzqq


    关闭好像转发区就不起作用了。

论坛徽章:
0
7 [报告]
发表于 2010-07-12 22:48 |只看该作者
recursion开启,将hint文件named.ca置空试试。

论坛徽章:
0
8 [报告]
发表于 2010-07-22 09:48 |只看该作者

论坛徽章:
0
9 [报告]
发表于 2010-07-22 10:01 |只看该作者
zone "baidu.com" IN{
type forward;
forward  only ;
forwarders {ip; };
};
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP