免费注册 查看新帖 |

Chinaunix

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

[DNS] 自己对BIND9配置模版很详细的注释,给大家分享 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-03-29 23:01 |只看该作者 |倒序浏览
本帖最后由 shellyxz 于 2011-03-29 23:05 编辑

示宽度不够,好像格式乱掉了,我把打包的配置文件附上吧。 named.tar.gz (4.51 KB, 下载次数: 275)
  1. //named.conf 注释说明 by shellyxz@163.com
  2. // 此文件对bind9的默认配置文件的说明
  3. //options 语句指定全局选项,对于某些特定区域服务器,某些选项以后可能会被覆盖。bind9的选项超过100个.....
  4. options
  5. {
  6.         // Those options should be used carefully because they disable port
  7.         // randomization
  8.         // query-source    port 53;       
  9.         // query-source-v6 port 53;
  10.        
  11.         // Put files that named is allowed to write in the data/ directory:
  12.         directory "/var/named"; //让named程序cd到指定的目录。任何输出文件也写入这个目录中
  13.         dump-file                 "data/cache_dump.db";//数据库路径,rndc dumpdb命令用到
  14.         statistics-file         "data/named_stats.txt";//服务器统计信息文件的路径,rndc stats使用
  15.         memstatistics-file         "data/named_mem_stats.txt";//每次访问的使用的内存信息

  16. };
  17. //日志处理方式配置,bind9有很强大的日志处理能力,可以满足不同用户的要求,具体要参考相关资料
  18. logging
  19. {
  20. /*      If you want to enable debugging, eg. using the 'rndc trace' command,
  21. *      named will try to write the 'named.run' file in the $directory (/var/named).
  22. *      By default, SELinux policy does not allow named to modify the /var/named directory,
  23. *      so put the default debug log file in data/ :
  24. */
  25.         channel default_debug {  //通道,消息能去的地方:syslog、文件或者/dev/null,这儿是bind中预先
  26.                                  //定义的default_debug通道,日志记录到named.run文件中,严重性为dynamic
  27.                 file "data/named.run";//文件通道
  28.                 severity dynamic;//严重性,也就是syslog中的级别
  29.                 print-category   yes;//不同的print选项增加或者减少消息前缀
  30.                 print-severity   yes;//增加严重性前缀
  31.         };       
  32. };
  33. //
  34. //
  35. //view语句用于创建分离式DNS(split DNS),view将一个用于控制哪些客户能看到哪个view的
  36. //访问列表,用于view中所有区的一些选项,最后还有区本身打包一起。语法如下:
  37. // view view-name {
  38. //         match-clients { address_match_list };
  39. //         view_optionl;.....
  40. //         zone_statement;....
  41. //    };
  42. view "localhost_resolver"  //配置仅缓存服务器的配置方法。
  43. {
  44. /* This view sets up named to be a localhost resolver ( caching only nameserver ).
  45. * If all you want is a caching-only nameserver, then you need only define this view:
  46. */
  47.         match-clients                 { localhost; };
  48. #######################################################################################################
  49.         //说明:match-clients 后面所给的是address_match_list,也就是访问控制列表(说明在这可以引用acl)
  50.         //有4个表是预先定义的:
  51.         //any  #所有主机
  52.         //localnets  #本地上所有主机
  53.         //localhost  #机器本身
  54.         //none       #没有任何主机
  55.         //总结:!!!在不同的view中,这是个很关键的位置,控制了不同的机器的查询(当然还有其他选项配合使用!!
  56. ########################################################################################################
  57.         match-destinations        { localhost; };
  58.         recursion yes;      // 运行递归查询
  59.         # all views must contain the root hints zone:
  60.         include "/etc/named.root.hints";
  61. //“hint”是一个列出根域(".")服务器的DNS记录的集合,可以使用以下方法生成
  62. //dig @f.root-servers.net . ns > named.root.hints
  63. //dig . ns > named.root.hints
  64. //前者直接从根得到结果,后者是来自于本地服务器的缓存,所以结果可能不正确,尽管概率很小

  65.         /* these are zones that contain definitions for all the localhost
  66.          * names and addresses, as recommended in RFC1912 - these names should
  67.          * ONLY be served to localhost clients:
  68.          */
  69.         include "/etc/named.rfc1912.zones";
  70. };
  71. view "internal" //内部view
  72. {
  73. /* This view will contain zones you want to serve only to "internal" clients
  74.    that connect via your directly attached LAN interfaces - "localnets" .
  75. */
  76.         match-clients                { localnets; };
  77.         //由于是内部view,所以是默认是localnets,也可以自己定义哪些主机可以访问,格式如下:
  78.         //match-clients     { 192.168.0.0/16; 206.168.198.192/28; };
  79.         match-destinations        { localnets; };
  80.         recursion yes;
  81.         // all views must contain the root hints zone:
  82.         include "/etc/named.root.hints";

  83.         // include "named.rfc1912.zones";
  84.         // you should not serve your rfc1912 names to non-localhost clients.

  85.         // These are your "authoritative" internal zones, and would probably
  86.         // also be included in the "localhost_resolver" view above :

  87.         zone "my.internal.zone" {
  88.                 type master;//区的类型,有:master(主)、slave(从)、stub(存根)、delegation-only(仅授权)
  89.                             //master:区的主服务器,必须在声明master区时提供一条file语句,文件是DNS资源记录的集合
  90.                             //slvae:区的从服务器,正常情况下从服务器保留区数据库的一个完整副本
  91.                             //stub:也是从服务器,但是和slave的区别是,只传送NS记录。
  92.                 file "my.internal.zone.db";//dns数据文件
  93. #############################################################################################################
  94. //当然这还有很多选项可以选择,选项的含义都很简单,从语义上可以看
  95. //allow-query { address_mathc_list }; [any]   
  96. //allow-transfer { address_match_list }; [any]
  97. //allow-update { address_match_list }; [none]
  98. //如果一个区用于动态更新,就会出现上面这个选项,列表说明可以发生更新的主机,动态更新仅适用于master区。动态更
  99. //新的概念另看其他资料。大体上是针对动态ip做的处理,bind让DHCP守护进程通知BIND它所做的地址分配情况,因而可随时
  100. //更新DNS数据库的内容,具体情况查阅相关资料
  101. ##############################################################################################################
  102.         };
  103.         zone "my.slave.internal.zone" { //区从服务器
  104.                 type slave;
  105.                 file "slaves/my.slave.internal.zone.db";
  106.                 masters { /* put master nameserver IPs here */ 127.0.0.1; } ;
  107.                 //masters语句列出了一台或则多台机器的ip地址,可以从这些ip地址得到区数据库。
  108.                 // put slave zones in the slaves/ directory so named can update them
  109.         };       
  110.         zone "my.ddns.internal.zone" { //动态更新区
  111.                 type master;           
  112.                                        
  113.                 allow-update { key ddns_key; }; //上面有说明
  114.                 file "slaves/my.ddns.internal.zone.db";
  115.                 // put dynamically updateable zones in the slaves/ directory so named can update them
  116.         };                       
  117. };
  118. //key语句定义了用于某个特定服务器身份验证的有名字的加密密钥。
  119. key ddns_key //ddns_key这是个key-id,key_id必须在首次使用之前在named.conf文件中定义
  120. {
  121.         algorithm hmac-md5; //加密算法,TSIG有多种加密算法,但是bind只实现了hmac-md5一种
  122.         secret "use /usr/sbin/dns-keygen to generate TSIG keys";
  123.         //用dns-keygen产生的TSIG(transaction signature)事物签名。TSGI只用于服务器之间的消息和响应上,
  124.         //而不用在服务器和解析器之间。事物签名验证双方的身份,证实数据没有被篡改过。
  125.         
  126. };
  127. ##############################################################################################
  128. //DNS安全的策略有访问控制列表、TSIG,还有DNSSEC,它是对DNS的扩展,使用公钥加密,对区数据的来源
  129. //进行验证,并验证完整性。DNSSEC依赖于一条信任链:根服务器提供顶级域的有效信息,顶级域提供二级
  130. //域的有效信息,以此类推。DNSSEC的配置说明如下:
  131. //trusted-keys语句用于实现RFC2535中规定的DNSSEC安全机制。该语句的每一项都是一个5元组,标识出与
  132. //该域的域名服务器进行安全通信所需的域名、标志、协议、算法和密钥。
  133. // trusted-keys{
  134. //       domain flags protol algorithm key;
  135. //       domain flags protol algorithm key;
  136. //             ....
  137. //              }
  138. ##############################################################################################
  139. view    "external"
  140. {
  141. /* This view will contain zones you want to serve only to "external" clients
  142. * that have addresses that are not on your directly attached LAN interface subnets:
  143. */
  144.         match-clients                { any; };
  145.         //这是外部view,所以允许所有主机查询
  146.         match-destinations        { any; };

  147.         recursion no;         
  148.         //对来自于外部的查询,禁止递归,一定程度上减轻服务器负担,提高安全
  149.         // you'd probably want to deny recursion to external clients, so you don't
  150.         // end up providing free DNS service to all takers

  151.         allow-query-cache { none; };//控制了查找缓存数据和根服务器线索文件的主机
  152.         // Disable lookups for any cached data and root hints

  153.         //每个view都必须包含线索文件,怎么得到线索文件上面有说明
  154.         include "/etc/named.root.hints";

  155.         // These are your "authoritative" external zones, and would probably
  156.         // contain entries for just your web and mail servers:
  157.         // 对外的权威区域
  158.         zone "my.external.zone" {
  159.                 type master;
  160.                 file "my.external.zone.db";
  161.         };
  162. };
  163. #################################################################################################
  164. # 以上就是named.conf原始配置文件的全部内容,当然要满足特定环境的需要还有很多东西需要改变或者添加                                                                                          
  165. # 下面做些总结:                                                                                
  166. # 1.DNS服务器有各种工作方式,缓存域名、转发、从域名、主域名、分离域名等方式,还可以配合起来使用;   
  167. # 2.split DNS的实现原理:通过view语句match-clients、match-destination等选项实现;                  
  168. # 3.每个view中必须包含hints文件,hints文件可以通过 dig @root-server . ns > file 的方式实现;     
  169. # 4.注意区数据文件里边的各种RR,记得在更新区数据文件后,一定提高SOA记录里serial number值;      
  170. #################################################################################################
复制代码

论坛徽章:
0
2 [报告]
发表于 2011-03-30 10:21 |只看该作者
很不错。值得分享!

论坛徽章:
0
3 [报告]
发表于 2011-03-30 23:11 |只看该作者
请问那个115到121那段有什么作用吗?我看不太懂。动态更新是指?

论坛徽章:
0
4 [报告]
发表于 2013-07-15 23:07 |只看该作者
很不错。值得分享!

论坛徽章:
24
天蝎座
日期:2014-05-13 18:05:59IT运维版块每日发帖之星
日期:2015-11-26 06:20:00操作系统版块每月发帖之星
日期:2015-12-02 14:57:54IT运维版块每月发帖之星
日期:2016-01-07 23:01:56IT运维版块每周发帖之星
日期:2016-01-07 23:04:2615-16赛季CBA联赛之青岛
日期:2016-01-23 07:58:272016猴年福章徽章
日期:2016-02-18 15:30:3415-16赛季CBA联赛之北控
日期:2016-03-23 14:20:06IT运维版块每日发帖之星
日期:2016-04-01 06:20:0015-16赛季CBA联赛之吉林
日期:2016-06-28 13:51:54IT运维版块每日发帖之星
日期:2016-07-01 06:20:00IT运维版块每日发帖之星
日期:2015-11-23 06:20:00
5 [报告]
发表于 2013-07-16 13:48 |只看该作者
有點亂有點淺.樓主如果你真心想給大象分享詳儘配置。應該舉出實例。那些配置參數網上一搜大把。
比如:
1.DDNS在網上流傳的有多種說法
  一種:動態解析域名、
  一種:只是動態解析內部電腦名稱代替wins服務器的功能而已。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP