一次关于DNS服务器的故障排错记录——RNDC故障

本文涉及的产品
公共DNS(含HTTPDNS解析),每月1000万次HTTP解析
云解析 DNS,旗舰版 1个月
全局流量管理 GTM,标准版 1个月
简介:
原创作品,允许转载,转载时请务必以超链接形式标明文章  原始出处 、作者信息和本声明。否则将追究法律责任。 http://dgd2010.blog.51cto.com/1539422/819526

说明:这是一篇对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.  
  31. Chain FORWARD (policy ACCEPT) 
  32. num  target     prot opt source               destination          
  33. 1    REJECT     all      ::/0                 ::/0                reject-with icmp6-adm-prohibited  
  34.  
  35. Chain OUTPUT (policy ACCEPT) 
  36. num  target     prot opt source               destination          
  37.  
  38. IPsec stopped 
  39. Table: filter 
  40. Chain INPUT (policy ACCEPT) 
  41. num  target     prot opt source               destination          
  42. 1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED  
  43. 2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            
  44. 3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            
  45. 4    ACCEPT     tcp  --  10.0.0.0/8           0.0.0.0/0           tcp dpt:953  
  46. 5    ACCEPT     tcp  --  10.0.0.0/8           0.0.0.0/0           tcp dpt:53  
  47. 6    ACCEPT     tcp  --  10.0.0.0/8           0.0.0.0/0           tcp dpt:443  
  48. 7    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22  
  49. 8    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited  
  50.  
  51. Chain FORWARD (policy ACCEPT) 
  52. num  target     prot opt source               destination          
  53. 1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited  
  54.  
  55. Chain OUTPUT (policy ACCEPT) 
  56. num  target     prot opt source               destination          
  57.  
  58. Table: mangle 
  59. Chain PREROUTING (policy ACCEPT) 
  60. num  target     prot opt source               destination          
  61.  
  62. Chain INPUT (policy ACCEPT) 
  63. num  target     prot opt source               destination          
  64.  
  65. Chain FORWARD (policy ACCEPT) 
  66. num  target     prot opt source               destination          
  67.  
  68. Chain OUTPUT (policy ACCEPT) 
  69. num  target     prot opt source               destination          
  70.  
  71. Chain POSTROUTING (policy ACCEPT) 
  72. num  target     prot opt source               destination          
  73.  
  74. Table: nat 
  75. Chain PREROUTING (policy ACCEPT) 
  76. num  target     prot opt source               destination          
  77.  
  78. Chain POSTROUTING (policy ACCEPT) 
  79. num  target     prot opt source               destination          
  80.  
  81. Chain OUTPUT (policy ACCEPT) 
  82. num  target     prot opt source               destination          
  83.  
  84. irqbalance (pid  1895) is running... 
  85. Kdump is operational 
  86. started 
  87. qpidd is stopped 
  88. matahari-qmf-hostd is stopped 
  89. matahari-qmf-networkd is stopped 
  90. matahari-qmf-serviced is stopped 
  91. matahari-qmf-sysconfigd is stopped 
  92. Checking for mcelog 
  93. mcelog is stopped 
  94. mdmonitor is stopped 
  95. messagebus (pid  1993) is running... 
  96. mysqld is stopped 
  97. rndc: connect failed: 127.0.0.1#953: connection refused 
  98. named is stopped 
  99. No open transaction 
  100. netconsole module not loaded 
  101. Configured devices: 
  102. lo eth0 
  103. Currently active devices: 
  104. lo eth0 
  105. NetworkManager (pid  2004) is running... 
  106. rpc.svcgssd is stopped 
  107. rpc.mountd is stopped 
  108. nfsd is stopped 
  109. rpc.rquotad is stopped 
  110. rpc.statd (pid  2037) is running... 
  111. nmbd is stopped 
  112. ntpd (pid  2243) is running... 
  113. oddjobd is stopped 
  114. portreserve (pid  1851) is running... 
  115. master (pid  2347) is running... 
  116. postmaster is stopped 
  117. Process accounting is disabled. 
  118. qpidd (pid  2390) is running... 
  119. quota_nld is stopped 
  120. rdisc is stopped 
  121. restorecond (pid 10836) is running... 
  122. rhnsd (pid  2445) is running... 
  123. rhsmcertd (pid 2457 2456) is running... 
  124. rngd is stopped 
  125. rpcbind (pid  1909) is running... 
  126. rpc.gssd is stopped 
  127. rpc.idmapd (pid 2076) is running... 
  128. rpc.svcgssd is stopped 
  129. rsyslogd (pid  1858) is running... 
  130. sandbox is stopped 
  131. saslauthd is stopped 
  132. sfcb is not running, but pid file exists 
  133. smartd is stopped 
  134. smbd is stopped 
  135. snmpd is stopped 
  136. snmptrapd is stopped 
  137. spamd is stopped 
  138. spice-vdagentd is stopped 
  139. openssh-daemon (pid  2233) is running... 
  140. sssd is stopped 
  141. CIM server (2470) is runningtomcat6 is stopped             [  OK  ] 
  142. vsftpd is stopped 
  143. wdaemon is stopped 
  144. Webmin (pid 2498) is running 
  145. wpa_supplicant (pid  2020) is running... 
  146. 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.  
  48. /etc/named: 
  49. total 16 
  50. drwxr-x---.   2 root named  4096 Dec 20 23:53 . 
  51. drwxr-xr-x. 131 root root  12288 Mar 28 14:32 .. 
  52. [root@localhost ~]# ls /etc/rndc.* -al 
  53. -rw-------. 1 root root 479 Mar 27 23:46 /etc/rndc.conf 
  54. -rw-------. 1 root root 479 Mar 28 13:42 /etc/rndc.conf.backup 
  55. -rw-------. 1 root root 479 Mar 27 23:10 /etc/rndc.conf.original 
  56. -rw-------. 1 root root 479 Mar 27 23:46 /etc/rndc.conf.original_1_error_secret 
  57. -rw-------. 1 root root 510 Mar 27 23:43 /etc/rndc.key.removed_no_need 
  58. -rw-------. 1 root root 511 Mar 27 23:50 /etc/rndc.key.removed_no_need_1 
  59. [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.  
  6. Chain POSTROUTING (policy ACCEPT) 
  7. num  target     prot opt source               destination          
  8.  
  9. Chain OUTPUT (policy ACCEPT) 
  10. num  target     prot opt source               destination          
  11.  
  12. Table: mangle 
  13. Chain PREROUTING (policy ACCEPT) 
  14. num  target     prot opt source               destination          
  15.  
  16. Chain INPUT (policy ACCEPT) 
  17. num  target     prot opt source               destination          
  18.  
  19. Chain FORWARD (policy ACCEPT) 
  20. num  target     prot opt source               destination          
  21.  
  22. Chain OUTPUT (policy ACCEPT) 
  23. num  target     prot opt source               destination          
  24.  
  25. Chain POSTROUTING (policy ACCEPT) 
  26. num  target     prot opt source               destination          
  27.  
  28. Table: filter 
  29. Chain INPUT (policy ACCEPT) 
  30. num  target     prot opt source               destination          
  31. 1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED  
  32. 2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            
  33. 3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            
  34. 4    ACCEPT     tcp  --  10.0.0.0/8           0.0.0.0/0           tcp dpt:953  
  35. 5    ACCEPT     tcp  --  10.0.0.0/8           0.0.0.0/0           tcp dpt:53  
  36. 6    ACCEPT     tcp  --  10.0.0.0/8           0.0.0.0/0           tcp dpt:443  
  37. 7    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22  
  38. 8    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited  
  39.  
  40. Chain FORWARD (policy ACCEPT) 
  41. num  target     prot opt source               destination          
  42. 1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited  
  43.  
  44. Chain OUTPUT (policy ACCEPT) 
  45. num  target     prot opt source               destination          
  46.  
  47. [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.  
  8. options { 
  9.     default-key "rndc-key"; 
  10.     default-server 127.0.0.1; 
  11.     default-port 953; 
  12. }; 
  13. # End of rndc.conf 
  14.  
  15. # Use with the following in named.conf, adjusting the allow list as needed: 
  16. # key "rndc-key" { 
  17. #   algorithm hmac-md5; 
  18. #   secret "cK1Bt77B8kL9uLpxy4GDTg=="; 
  19. # }; 
  20. #  
  21. # controls { 
  22. #   inet 127.0.0.1 port 953 
  23. #       allow { 127.0.0.1; } keys { "rndc-key"; }; 
  24. # }; 
  25. # 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.  
  11. options { 
  12.     listen-on port 53 { 127.0.0.1; }; 
  13.     listen-on-v6 port 53 { ::1; }; 
  14.     directory   "/var/named"; 
  15.     dump-file   "/var/named/data/cache_dump.db"; 
  16.         statistics-file "/var/named/data/named_stats.txt"; 
  17.         memstatistics-file "/var/named/data/named_mem_stats.txt"; 
  18.     allow-query     { localhost; }; 
  19.     recursion yes; 
  20.  
  21.     dnssec-enable yes; 
  22.     dnssec-validation yes; 
  23.     dnssec-lookaside auto; 
  24.  
  25.     /* Path to ISC DLV key */ 
  26.     bindkeys-file "/etc/named.iscdlv.key"; 
  27. }; 
  28.  
  29. logging { 
  30.         channel default_debug { 
  31.                 file "data/named.run"; 
  32.                 severity dynamic; 
  33.         }; 
  34. }; 
  35.  
  36. zone "." IN { 
  37.     type hint; 
  38.     file "named.ca"; 
  39. }; 
  40.  
  41. 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.  
  11. options { 
  12.     listen-on port 53 { 127.0.0.1; }; 
  13.     listen-on-v6 port 53 { ::1; }; 
  14.     directory   "/var/named"; 
  15.     dump-file   "/var/named/data/cache_dump.db"; 
  16.         statistics-file "/var/named/data/named_stats.txt"; 
  17.         memstatistics-file "/var/named/data/named_mem_stats.txt"; 
  18.     allow-query     { localhost; }; 
  19.     recursion yes; 
  20.  
  21.     dnssec-enable yes; 
  22.     dnssec-validation yes; 
  23.     dnssec-lookaside auto; 
  24.  
  25.     /* Path to ISC DLV key */ 
  26.     bindkeys-file "/etc/named.iscdlv.key"; 
  27. }; 
  28.  
  29. logging { 
  30.         channel default_debug { 
  31.                 file "data/named.run"; 
  32.                 severity dynamic; 
  33.         }; 
  34. }; 
  35.  
  36. zone "." IN { 
  37.     type hint; 
  38.     file "named.ca"; 
  39. }; 
  40.  
  41. include "/etc/named.rfc1912.zones"; 
  42. # Add line to enable named working with "/etc/rndc.conf" 
  43.  
  44. # Use with the following in named.conf, adjusting the allow list as needed: 
  45. key "rndc-key" { 
  46.        algorithm hmac-md5; 
  47.        secret "cK1Bt77B8kL9uLpxy4GDTg=="; 
  48. }; 
  49.  
  50. controls { 
  51.       inet 127.0.0.1 port 953 
  52.               allow { 127.0.0.1; } keys { "rndc-key"; }; 
  53. }; 
  54. # End of named.conf 
  55.  
  56. [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 ~]#  

最后总结

        其实问题的出现不一定就是存在硬错误,还可能存在软错误。就像C编程一样,有的语法错误,编译器或语法检查器能帮你识别并找出错误,但是在算法上的逻辑错误只能由编程人员自己发现和纠正。在配置Linux网络服务器时同样也可能遇到这类问题,只要管理员仔细查看问题,检查日志就很快发现问题的所在。希望在今后的工作中能更多的总结和发现、解决问题的思路,大胆的却有根据的自己去发现和解决问题。

本文出自 “通信,我的最爱” 博客,请务必保留此出处http://dgd2010.blog.51cto.com/1539422/819526

目录
打赏
0
0
0
0
248
分享
相关文章
服务器数据恢复—服务器raid磁盘出现故障的数据恢复案例
一台服务器中有一组由三块SAS硬盘组建的raid阵列。服务器上部署的数据库存储在D分区,数据库备份存储在E分区。 服务器上一块硬盘指示灯显示红色。D分区不可识别。E分区虽然可以识别,但是E分区拷贝文件报错。 管理员重启服务器,先离线的硬盘上线开始同步数据,同步没有完成的情况下管理员将服务器强制关机,之后没有动过服务器。
阿里云服务器实例选择指南:热门实例性能、适用场景解析对比参考
2025年,在阿里云的活动中,主售的云服务器实例规格除了轻量应用服务器之外,还有经济型e、通用算力型u1、计算型c8i、通用型g8i、计算型c7、计算型c8y、通用型g7、通用型g8y、内存型r7、内存型r8y等,以满足不同用户的需求。然而,面对众多实例规格,用户往往感到困惑,不知道如何选择。本文旨在全面解析阿里云服务器实例的各种类型,包括经济型、通用算力型、计算型、通用型和内存型等,以供参考和选择。
服务器数据恢复—如何预防服务器故障?服务器发生故障如何恢复数据?
服务器常见故障: 硬件故障:磁盘损坏、电池故障等。 软件问题:操作系统崩溃、未知的程序运行错误等。 病毒破坏:勒索病毒加密、删除服务器数据等。 不可控力量;服务器浸水、火烧、机房倒塌等导致服务器损坏和数据丢失。 误操作:工作人员操作失误导致数据丢失,如格式化、删除、覆盖等。
38 16
服务器数据恢复—如何预防服务器故障?服务器发生故障如何恢复数据?
阿里云服务器架构解析:从X86到高性能计算、异构计算等不同架构性能、适用场景及选择参考
当我们准备选购阿里云服务器时,阿里云提供了X86计算、ARM计算、GPU/FPGA/ASIC、弹性裸金属服务器以及高性能计算等多种架构,每种架构都有其独特的特点和适用场景。本文将详细解析这些架构的区别,探讨它们的主要特点和适用场景,并为用户提供选择云服务器架构的全面指南。
阿里云操作系统控制台——解决服务器磁盘I/O故障
阿里云操作系统控制台——解决服务器磁盘I/O故障
44 12
阿里云服务器第八代通用型g8i实例评测:性能与适用场景解析
阿里云服务器通用型g8i实例怎么样?g8i实例采用CIPU+飞天技术架构,并搭载最新的Intel 第五代至强可扩展处理器(代号EMR),不仅性能得到大幅提升,同时还拥有AMX加持的AI能力增强,以及全球范围内率先支持的TDX机密虚拟机能力。这些特性使得g8i实例在AI增强和全面安全防护两大方面表现出色,尤其适用于在线音视频及AI相关应用。本文将深入探讨g8i实例的产品特性、优势、适用场景及规格族,以帮助您更好地了解这款产品,以供参考和选择。
新手上云教程参考:阿里云服务器租用、域名注册、备案及域名解析流程图文教程
对于想要在阿里云上搭建网站或应用的用户来说,购买阿里云服务器和注册域名,绑定以及备案的流程至关重要。本文将以图文形式为您介绍阿里云服务器购买、域名注册、备案及绑定的全流程,以供参考,帮助用户轻松上手。
阿里云服务器经济型e实例解析:性能、稳定性与兼顾成本
阿里云经济型e云服务器以其高性价比、稳定可靠的性能以及灵活多样的配置选项,成为了众多企业在搭建官网时的首选。那么,阿里云经济型e云服务器究竟怎么样?它是否能够满足企业官网的搭建需求?本文将从性能表现、稳定性与可靠性、成本考虑等多个方面对阿里云经济型e云服务器进行深入剖析,以供大家参考选择。
173 37
2025年阿里云弹性裸金属服务器架构解析与资源配置方案
🚀 核心特性与技术创新:提供100%物理机性能输出,支持NVIDIA A100/V100 GPU直通,无虚拟化层损耗。网络与存储优化,400万PPS吞吐量,ESSD云盘IOPS达100万,RDMA延迟<5μs。全球部署覆盖华北、华东、华南及海外节点,支持跨地域负载均衡。典型应用场景包括AI训练、科学计算等,支持分布式训练和并行计算框架。弹性裸金属服务器+OSS存储+高速网络综合部署,满足高性能计算需求。
阿里云轻量应用服务器产品解析与搭建个人博客网站教程参考
轻量应用服务器(Simple Application Server)作为阿里云面向单机应用场景推出的云服务器产品,以其一键部署、一站式管理、高性价比等特性,深受个人开发者、中小企业及入门级用户的喜爱。本文将全面解析阿里云轻量应用服务器的产品优势、应用场景、使用须知,以及使用轻量应用服务器搭建个人博客网站的详细教程,帮助用户更好地了解和使用这一产品。

相关产品

  • 云解析DNS
  • 推荐镜像

    更多