说明:这是一篇对DNS排错的文章,因为在网上(包括RedHat知识库)几乎没有对文中提到的错误进行直接描述和提出最好最快的解决方案的报告,经过长达近一个小时的排错和资料查阅才有了这篇文章的脱稿。

昨天我刚刚在非生产环境中的Red Hat Enterprise Linux Server上配置了一台DNS服务器,以做测试使用。但是很快遇到了一个奇怪的错误。

我在执行“service named status”后,其中第一行显示如下内容:

  1. [root@localhost ~]# service named status

  2. rndc: connect failed: 127.0.0.1#953: connection refused

  3. named (pid 6207) is running...

  4. [root@localhost ~]#

一般大家都知道,rndc 主要是用来控制named进程及其配置文件的,可以用来连接DNS服务器并对配置进行重新载入,其端口号就是953。那么导致这个错误的原因可能是什么呢?

我的解决思路:

首先,发现问题,仔细阅读查看命令的回显信息。例如我详细的查看service的状态信息。

  1. [root@localhost gdd]# service --status-all

  2. abrtd (pid 2371) is running...

  3. abrt-dump-oops (pid 2379) is running...

  4. acpid (pid 2111) is running...

  5. atd (pid 5396) is running...

  6. auditd (pid 1833) is running...

  7. automount (pid 2195) is running...

  8. avahi-daemon (pid 2016) is running...

  9. Usage: /etc/init.d/bluetooth {start|stop}

  10. certmonger is stopped

  11. Stopped

  12. cgred is stopped

  13. Frequency scaling enabled using ondemand governor

  14. crond (pid 2423) is running...

  15. cupsd (pid 2086) is running...

  16. dnsmasq is stopped

  17. dovecot is stopped

  18. Usage: /etc/init.d/firstboot {start|stop}

  19. hald (pid 2120) is running...

  20. I don't know of any running hsqldb server.

  21. httpd (pid 6595) is running...

  22. Table: filter

  23. Chain INPUT (policy ACCEPT)

  24. num target prot opt source destination

  25. 1 ACCEPT all ::/0 ::/0 state RELATED,ESTABLISHED

  26. 2 ACCEPT icmpv6 ::/0 ::/0

  27. 3 ACCEPT all ::/0 ::/0

  28. 4 ACCEPT tcp ::/0 ::/0 state NEW tcp dpt:22

  29. 5 REJECT all ::/0 ::/0 reject-with icmp6-adm-prohibited

  30. Chain FORWARD (policy ACCEPT)

  31. num target prot opt source destination

  32. 1 REJECT all ::/0 ::/0 reject-with icmp6-adm-prohibited

  33. Chain OUTPUT (policy ACCEPT)

  34. num target prot opt source destination

  35. IPsec stopped

  36. Table: filter

  37. Chain INPUT (policy ACCEPT)

  38. num target prot opt source destination

  39. 1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

  40. 2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0

  41. 3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0

  42. 4 ACCEPT tcp -- 10.0.0.0/8 0.0.0.0/0 tcp dpt:953

  43. 5 ACCEPT tcp -- 10.0.0.0/8 0.0.0.0/0 tcp dpt:53

  44. 6 ACCEPT tcp -- 10.0.0.0/8 0.0.0.0/0 tcp dpt:443

  45. 7 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22

  46. 8 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

  47. Chain FORWARD (policy ACCEPT)

  48. num target prot opt source destination

  49. 1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

  50. Chain OUTPUT (policy ACCEPT)

  51. num target prot opt source destination

  52. Table: mangle

  53. Chain PREROUTING (policy ACCEPT)

  54. num target prot opt source destination

  55. Chain INPUT (policy ACCEPT)

  56. num target prot opt source destination

  57. Chain FORWARD (policy ACCEPT)

  58. num target prot opt source destination

  59. Chain OUTPUT (policy ACCEPT)

  60. num target prot opt source destination

  61. Chain POSTROUTING (policy ACCEPT)

  62. num target prot opt source destination

  63. Table: nat

  64. Chain PREROUTING (policy ACCEPT)

  65. num target prot opt source destination

  66. Chain POSTROUTING (policy ACCEPT)

  67. num target prot opt source destination

  68. Chain OUTPUT (policy ACCEPT)

  69. num target prot opt source destination

  70. irqbalance (pid 1895) is running...

  71. Kdump is operational

  72. started

  73. qpidd is stopped

  74. matahari-qmf-hostd is stopped

  75. matahari-qmf-networkd is stopped

  76. matahari-qmf-serviced is stopped

  77. matahari-qmf-sysconfigd is stopped

  78. Checking for mcelog

  79. mcelog is stopped

  80. mdmonitor is stopped

  81. messagebus (pid 1993) is running...

  82. mysqld is stopped

  83. rndc: connect failed: 127.0.0.1#953: connection refused

  84. named is stopped

  85. No open transaction

  86. netconsole module not loaded

  87. Configured devices:

  88. lo eth0

  89. Currently active devices:

  90. lo eth0

  91. NetworkManager (pid 2004) is running...

  92. rpc.svcgssd is stopped

  93. rpc.mountd is stopped

  94. nfsd is stopped

  95. rpc.rquotad is stopped

  96. rpc.statd (pid 2037) is running...

  97. nmbd is stopped

  98. ntpd (pid 2243) is running...

  99. oddjobd is stopped

  100. portreserve (pid 1851) is running...

  101. master (pid 2347) is running...

  102. postmaster is stopped

  103. Process accounting is disabled.

  104. qpidd (pid 2390) is running...

  105. quota_nld is stopped

  106. rdisc is stopped

  107. restorecond (pid 10836) is running...

  108. rhnsd (pid 2445) is running...

  109. rhsmcertd (pid 2457 2456) is running...

  110. rngd is stopped

  111. rpcbind (pid 1909) is running...

  112. rpc.gssd is stopped

  113. rpc.idmapd (pid 2076) is running...

  114. rpc.svcgssd is stopped

  115. rsyslogd (pid 1858) is running...

  116. sandbox is stopped

  117. saslauthd is stopped

  118. sfcb is not running, but pid file exists

  119. smartd is stopped

  120. smbd is stopped

  121. snmpd is stopped

  122. snmptrapd is stopped

  123. spamd is stopped

  124. spice-vdagentd is stopped

  125. openssh-daemon (pid 2233) is running...

  126. sssd is stopped

  127. CIM server (2470) is runningtomcat6 is stopped [ OK ]

  128. vsftpd is stopped

  129. wdaemon is stopped

  130. Webmin (pid 2498) is running

  131. wpa_supplicant (pid 2020) is running...

  132. ypbind is stopped

很显然,上面的显示中的第97行显示的

  • rndc: connect failed: 127.0.0.1#953: connection refused

  • named is stopped

是错误的信息。

然后我开始查看系统日志,显示结果如下:

  1. [root@localhost ~]# named -g

  2. 28-Mar-2012 13:27:58.722 starting BIND 9.7.3-P3-RedHat-9.7.3-8.P3.el6_2.2 -g

  3. 28-Mar-2012 13:27:58.722 built with '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-libtool' '--localstatedir=/var' '--enable-threads' '--enable-ipv6' '--with-pic' '--disable-static' '--disable-openssl-version-check' '--with-dlz-ldap=yes' '--with-dlz-postgres=yes' '--with-dlz-mysql=yes' '--with-dlz-filesystem=yes' '--with-gssapi=yes' '--disable-isc-spnego' '--with-docbook-xsl=/usr/share/sgml/docbook/xsl-stylesheets' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'target_alias=x86_64-redhat-linux-gnu' 'CFLAGS= -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' 'CPPFLAGS= -DDIG_SIGCHASE'

  4. 28-Mar-2012 13:27:58.722 adjusted limit on open files from 1024 to 1048576

  5. 28-Mar-2012 13:27:58.722 found 2 CPUs, using 2 worker threads

  6. 28-Mar-2012 13:27:58.723 using up to 4096 sockets

  7. 28-Mar-2012 13:27:58.734 loading configuration from '/etc/named.conf'

  8. 28-Mar-2012 13:27:58.735 reading built-in trusted keys from file '/etc/named.iscdlv.key'

  9. 28-Mar-2012 13:27:58.736 using default UDP/IPv4 port range: [1024, 65535]

  10. 28-Mar-2012 13:27:58.737 using default UDP/IPv6 port range: [1024, 65535]

  11. 28-Mar-2012 13:27:58.740 listening on IPv4 interface lo, 127.0.0.1#53

  12. 28-Mar-2012 13:27:58.744 binding TCP socket: address in use

  13. 28-Mar-2012 13:27:58.744 listening on IPv6 interface lo, ::1#53

  14. 28-Mar-2012 13:27:58.745 binding TCP socket: address in use

  15. 28-Mar-2012 13:27:58.747 could not open file '/var/run/named/named.pid': Permission denied

  16. 28-Mar-2012 13:27:58.747 generating session key for dynamic DNS

  17. 28-Mar-2012 13:27:58.747 could not open file '/var/run/named/session.key': Permission denied

  18. 28-Mar-2012 13:27:58.747 could not create /var/run/named/session.key

  19. 28-Mar-2012 13:27:58.747 failed to generate session key for dynamic DNS: permission denied

  20. 28-Mar-2012 13:27:58.753 using built-in trusted-keys for view _default

  21. 28-Mar-2012 13:27:58.754 set up managed keys zone for view _default, file 'dynamic/managed-keys.bind'

  22. 28-Mar-2012 13:27:58.754 automatic empty zone: 127.IN-ADDR.ARPA

  23. 28-Mar-2012 13:27:58.754 automatic empty zone: 254.169.IN-ADDR.ARPA

  24. 28-Mar-2012 13:27:58.754 automatic empty zone: 2.0.192.IN-ADDR.ARPA

  25. 28-Mar-2012 13:27:58.754 automatic empty zone: 100.51.198.IN-ADDR.ARPA

  26. 28-Mar-2012 13:27:58.754 automatic empty zone: 113.0.203.IN-ADDR.ARPA

  27. 28-Mar-2012 13:27:58.754 automatic empty zone: 255.255.255.255.IN-ADDR.ARPA

  28. 28-Mar-2012 13:27:58.754 automatic empty zone: 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA

  29. 28-Mar-2012 13:27:58.754 automatic empty zone: D.F.IP6.ARPA

  30. 28-Mar-2012 13:27:58.754 automatic empty zone: 8.E.F.IP6.ARPA

  31. 28-Mar-2012 13:27:58.754 automatic empty zone: 9.E.F.IP6.ARPA

  32. 28-Mar-2012 13:27:58.754 automatic empty zone: A.E.F.IP6.ARPA

  33. 28-Mar-2012 13:27:58.754 automatic empty zone: B.E.F.IP6.ARPA

  34. 28-Mar-2012 13:27:58.755 automatic empty zone: 8.B.D.0.1.0.0.2.IP6.ARPA

  35. 28-Mar-2012 13:27:58.759 none:0: open: /etc/rndc.key: file not found

  36. 28-Mar-2012 13:27:58.760 couldn't add command channel 127.0.0.1#953: file not found

  37. 28-Mar-2012 13:27:58.760 none:0: open: /etc/rndc.key: file not found

  38. 28-Mar-2012 13:27:58.760 couldn't add command channel ::1#953: file not found

  39. 28-Mar-2012 13:27:58.760 ignoring config file logging statement due to -g option

  40. 28-Mar-2012 13:27:58.761 zone 0.in-addr.arpa/IN: loaded serial 0

  41. 28-Mar-2012 13:27:58.762 zone 1.0.0.127.in-addr.arpa/IN: loaded serial 0

  42. 28-Mar-2012 13:27:58.764 zone 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa/IN: loaded serial 0

  43. 28-Mar-2012 13:27:58.765 zone localhost.localdomain/IN: loaded serial 0

  44. 28-Mar-2012 13:27:58.766 zone localhost/IN: loaded serial 0

  45. 28-Mar-2012 13:27:58.766 managed-keys-zone ./IN: loading from master file dynamic/managed-keys.bind failed: permission denied

  46. 28-Mar-2012 13:27:58.766 dynamic/managed-keys.bind.jnl: open: permission denied

  47. 28-Mar-2012 13:27:58.766 managed-keys-zone ./IN: journal rollforward failed: unexpected error

  48. 28-Mar-2012 13:27:58.767 running

很明显,根据上面的结果第35,37,46行的提示很可能是权限或者配置文件的错误造成的。所以下面一一检查即可。

首先不是权限的问题。我查看了所有DNS相关的所有配置文件,展示如下,也为大家以后出错作为参考。因为使用root登录终端对文件或目录执行移动或创建工作很容易导致权限问题。

  1. [root@localhost ~]# ls /var/named/ -al

  2. total 40

  3. drwxr-x---. 6 root named 4096 Mar 28 13:05 .

  4. drwxr-xr-x. 28 root root 4096 Mar 28 13:44 ..

  5. drwxr-x---. 6 root named 4096 Mar 28 13:05 chroot

  6. drwxrwx---. 2 named named 4096 Mar 28 13:23 data

  7. drwxrwx---. 2 named named 4096 Mar 28 15:24 dynamic

  8. -rw-r-----. 1 root named 1892 Feb 18 2008 named.ca

  9. -rw-r-----. 1 root named 152 Dec 15 2009 named.empty

  10. -rw-r-----. 1 root named 152 Jun 21 2007 named.localhost

  11. -rw-r-----. 1 root named 168 Dec 15 2009 named.loopback

  12. drwxrwx---. 2 named named 4096 Dec 20 23:53 slaves

  13. [root@localhost ~]# ls /var/named/chroot/ -al

  14. total 24

  15. drwxr-x---. 6 root named 4096 Mar 28 13:05 .

  16. drwxr-x---. 6 root named 4096 Mar 28 13:05 ..

  17. drwxr-x---. 2 root named 4096 Mar 28 13:05 dev

  18. drwxr-x---. 4 root named 4096 Mar 28 14:32 etc

  19. drwxr-xr-x. 3 root root 4096 Mar 28 13:05 usr

  20. drwxr-x---. 6 root named 4096 Mar 28 13:05 var

  21. [root@localhost ~]# ls /var/named/chroot/etc/ -al

  22. total 40

  23. drwxr-x---. 4 root named 4096 Mar 28 14:32 .

  24. drwxr-x---. 6 root named 4096 Mar 28 13:05 ..

  25. -rw-r--r--. 1 root root 405 Oct 19 22:00 localtime

  26. drwxr-x---. 2 root named 4096 Dec 20 23:53 named

  27. -rw-r-----. 1 root named 1259 Mar 28 14:31 named.conf

  28. -rw-r--r--. 1 root named 2544 Dec 20 23:53 named.iscdlv.key

  29. -rw-r-----. 1 root named 931 Jun 21 2007 named.rfc1912.zones

  30. -rw-r--r--. 1 root named 487 Dec 20 23:53 named.root.key

  31. drwxr-xr-x. 3 root root 4096 Mar 28 13:05 pki

  32. -rw-------. 1 root root 479 Mar 27 23:46 rndc.conf

  33. [root@localhost ~]# ls /var/named/chroot/var -al

  34. total 24

  35. drwxr-x---. 6 root named 4096 Mar 28 13:05 .

  36. drwxr-x---. 6 root named 4096 Mar 28 13:05 ..

  37. drwxrwx---. 2 named named 4096 Dec 20 23:53 log

  38. drwxr-x---. 6 root named 4096 Mar 28 13:05 named

  39. drwxr-x---. 3 root named 4096 Mar 28 13:05 run

  40. drwxrwx---. 2 named named 4096 Dec 20 23:53 tmp

  41. [root@localhost ~]# ls /etc/named* -al

  42. -rw-r-----. 1 root named 1259 Mar 28 14:31 /etc/named.conf

  43. -rw-r-----. 1 root root 930 Mar 28 13:41 /etc/named.conf.backup

  44. -rw-r--r--. 1 root named 2544 Dec 20 23:53 /etc/named.iscdlv.key

  45. -rw-r-----. 1 root named 931 Jun 21 2007 /etc/named.rfc1912.zones

  46. -rw-r--r--. 1 root named 487 Dec 20 23:53 /etc/named.root.key

  47. /etc/named:

  48. total 16

  49. drwxr-x---. 2 root named 4096 Dec 20 23:53 .

  50. drwxr-xr-x. 131 root root 12288 Mar 28 14:32 ..

  51. [root@localhost ~]# ls /etc/rndc.* -al

  52. -rw-------. 1 root root 479 Mar 27 23:46 /etc/rndc.conf

  53. -rw-------. 1 root root 479 Mar 28 13:42 /etc/rndc.conf.backup

  54. -rw-------. 1 root root 479 Mar 27 23:10 /etc/rndc.conf.original

  55. -rw-------. 1 root root 479 Mar 27 23:46 /etc/rndc.conf.original_1_error_secret

  56. -rw-------. 1 root root 510 Mar 27 23:43 /etc/rndc.key.removed_no_need

  57. -rw-------. 1 root root 511 Mar 27 23:50 /etc/rndc.key.removed_no_need_1

  58. [root@localhost ~]#

通过比对之前的备份,发现在权限上没有问题。

PS:如果大家遇到这方面的问题请使用如下的命令进行修改。

  1. su -

  2. chown -R root:named /derectory/directory/file

那么既然不是权限的问题,是不是iptables给设定的规则不正确呢?

查看iptables配置信息,显示如下:

  1. [root@localhost ~]# service iptables status

  2. Table: nat

  3. Chain PREROUTING (policy ACCEPT)

  4. num target prot opt source destination

  5. Chain POSTROUTING (policy ACCEPT)

  6. num target prot opt source destination

  7. Chain OUTPUT (policy ACCEPT)

  8. num target prot opt source destination

  9. Table: mangle

  10. Chain PREROUTING (policy ACCEPT)

  11. num target prot opt source destination

  12. Chain INPUT (policy ACCEPT)

  13. num target prot opt source destination

  14. Chain FORWARD (policy ACCEPT)

  15. num target prot opt source destination

  16. Chain OUTPUT (policy ACCEPT)

  17. num target prot opt source destination

  18. Chain POSTROUTING (policy ACCEPT)

  19. num target prot opt source destination

  20. Table: filter

  21. Chain INPUT (policy ACCEPT)

  22. num target prot opt source destination

  23. 1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

  24. 2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0

  25. 3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0

  26. 4 ACCEPT tcp -- 10.0.0.0/8 0.0.0.0/0 tcp dpt:953

  27. 5 ACCEPT tcp -- 10.0.0.0/8 0.0.0.0/0 tcp dpt:53

  28. 6 ACCEPT tcp -- 10.0.0.0/8 0.0.0.0/0 tcp dpt:443

  29. 7 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22

  30. 8 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

  31. Chain FORWARD (policy ACCEPT)

  32. num target prot opt source destination

  33. 1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

  34. Chain OUTPUT (policy ACCEPT)

  35. num target prot opt source destination

  36. [root@localhost ~]#

显然,不是iptables的配置有问题。再者,iptables如果有策略在阻止访问,其错误信息也不是如上面所示。

最终我诊断为可能是/etc/named.conf 配置文件存在问题。

因此进行检查配置文件,操作和显示如下:

  1. [root@localhost ~]# named-checkconf /etc/named.conf

  2. [root@localhost ~]# named-checkconf -t /var/named/chroot/

  3. [root@localhost ~]#

说明,在参数上没有问题。因此我开始怀疑,是不是/etc/named.conf或者/etc/rndc.conf存在配置错误?但是,作为新配置安装的DNS不会在密钥上出现问题,因此我检查了/etc/named.conf,确实没发现什么错误。然后我检查了/etc/rndc.conf这个文件,终于发现问题的所在。

结果如下:


  1. [root@localhost ~]# cat /etc/rndc.conf

  2. # Start of rndc.conf

  3. key "rndc-key" {

  4. algorithm hmac-md5;

  5. secret "cK1Bt77B8kL9uLpxy4GDTg==";

  6. };

  7. options {

  8. default-key "rndc-key";

  9. default-server 127.0.0.1;

  10. default-port 953;

  11. };

  12. # End of rndc.conf

  13. # Use with the following in named.conf, adjusting the allow list as needed:

  14. # key "rndc-key" {

  15. # algorithm hmac-md5;

  16. # secret "cK1Bt77B8kL9uLpxy4GDTg==";

  17. # };

  18. #

  19. # controls {

  20. # inet 127.0.0.1 port 953

  21. # allow { 127.0.0.1; } keys { "rndc-key"; };

  22. # };

  23. # End of named.conf

显然,最后的注释说的很清楚,要想使用rndc就必须在/etc/named.conf中进行配置。

所以将显示如下的/etc/named.conf第一段代码更改为第二段代码。

第一段代码:

  1. [root@localhost ~]# cat /etc/named.conf

  2. //

  3. // named.conf

  4. //

  5. // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS

  6. // server as a caching only nameserver (as a localhost DNS resolver only).

  7. //

  8. // See /usr/share/doc/bind*/sample/ for example named configuration files.

  9. //

  10. options {

  11. listen-on port 53 { 127.0.0.1; };

  12. listen-on-v6 port 53 { ::1; };

  13. directory "/var/named";

  14. dump-file "/var/named/data/cache_dump.db";

  15. statistics-file "/var/named/data/named_stats.txt";

  16. memstatistics-file "/var/named/data/named_mem_stats.txt";

  17. allow-query { localhost; };

  18. recursion yes;

  19. dnssec-enable yes;

  20. dnssec-validation yes;

  21. dnssec-lookaside auto;

  22. /* Path to ISC DLV key */

  23. bindkeys-file "/etc/named.iscdlv.key";

  24. };

  25. logging {

  26. channel default_debug {

  27. file "data/named.run";

  28. severity dynamic;

  29. };

  30. };

  31. zone "." IN {

  32. type hint;

  33. file "named.ca";

  34. };

  35. include "/etc/named.rfc1912.zones";

第二段代码:

  1. [root@localhost ~]# cat /etc/named.conf

  2. //

  3. // named.conf

  4. //

  5. // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS

  6. // server as a caching only nameserver (as a localhost DNS resolver only).

  7. //

  8. // See /usr/share/doc/bind*/sample/ for example named configuration files.

  9. //

  10. options {

  11. listen-on port 53 { 127.0.0.1; };

  12. listen-on-v6 port 53 { ::1; };

  13. directory "/var/named";

  14. dump-file "/var/named/data/cache_dump.db";

  15. statistics-file "/var/named/data/named_stats.txt";

  16. memstatistics-file "/var/named/data/named_mem_stats.txt";

  17. allow-query { localhost; };

  18. recursion yes;

  19. dnssec-enable yes;

  20. dnssec-validation yes;

  21. dnssec-lookaside auto;

  22. /* Path to ISC DLV key */

  23. bindkeys-file "/etc/named.iscdlv.key";

  24. };

  25. logging {

  26. channel default_debug {

  27. file "data/named.run";

  28. severity dynamic;

  29. };

  30. };

  31. zone "." IN {

  32. type hint;

  33. file "named.ca";

  34. };

  35. include "/etc/named.rfc1912.zones";

  36. # Add line to enable named working with "/etc/rndc.conf"

  37. # Use with the following in named.conf, adjusting the allow list as needed:

  38. key "rndc-key" {

  39. algorithm hmac-md5;

  40. secret "cK1Bt77B8kL9uLpxy4GDTg==";

  41. };

  42. controls {

  43. inet 127.0.0.1 port 953

  44. allow { 127.0.0.1; } keys { "rndc-key"; };

  45. };

  46. # End of named.conf

  47. [root@localhost ~]#

最后,重新启动named守护进程

  1. su -

  2. service named restart

  3. service named status

结果显示如下,就表示可以了。

  1. [root@localhost ~]# service named status

  2. version: 9.7.3-P3-RedHat-9.7.3-8.P3.el6_2.2

  3. CPUs found: 2

  4. worker threads: 2

  5. number of zones: 19

  6. debug level: 0

  7. xfers running: 0

  8. xfers deferred: 0

  9. soa queries in progress: 0

  10. query logging is OFF

  11. recursive clients: 0/0/1000

  12. tcp clients: 0/100

  13. server is up and running

  14. named (pid 11918) is running...

  15. [root@localhost ~]#