CentOS下搭建DNS服务器

DNS是域名系统(Domain Name System)的缩写,是因特网的一项核心服务,它能提供域名与IP地址之间对应关系的转换服务 。
这样我们就可以更方便地去访问互联网了,不用去记住那一串IP数字 。本文档主要是说明如何把一台centos主机配置成一个DNS
服务器,以便能提供域名解析服务 。
 
 
(1) DNS服务器端配置
操作系统:CentOS 6.4
IP地址:172.16.1.4
DNS软件:Bind 9.8
【CentOS下搭建DNS服务器】测试域名:realhostip.com
作用:主要提供解析realhostip.com域名的服务
 
1. 安装bind
# yum install bind
 
 
2. 修改/etc/named.conf配置文件
# vi /etc/named.conf
[html] view plaincopy

  1. //
  2. // named.conf
  3. //
  4. // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
  5. // server as a caching only nameserver (as a localhost DNS resolver only).
  6. //
  7. // See /usr/share/doc/bind*/sample/ for example named configuration files.
  8. //
  9.  
  10. options {
  11. listen-on port 53 { any; }; //开启监听端口53,接受任意IP连接
  12. listen-on-v6 port 53 { ::1; }; //支持IP V6
  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 { 0.0.0.0/0; }; //允许任意IP查询
  18. recursion yes;
  19.  
  20. dnssec-enable yes;
  21. dnssec-validation yes;
  22. dnssec-lookaside auto;
  23.  
  24. /* Path to ISC DLV key */
  25. bindkeys-file "/etc/named.iscdlv.key";
  26.  
  27. managed-keys-directory "/var/named/dynamic";
  28. };
  29.  
  30. logging {
  31. channel default_debug {
  32. file "data/named.run";
  33. severity dynamic;
  34. };
  35. };
  36.  
  37. zone "." IN {
  38. type hint;
  39. file "named.ca";
  40. };
  41.  
  42. include "/etc/named.rfc1912.zones"; //主要配置文件
  43. include "/etc/named.root.key";
 
3. 修改/etc/named.rfc1912.zones文件,添加realhostip.com的正向和反向区域
# vi /etc/ named.rfc1912.zones
[html] view plaincopy
  1. // named.rfc1912.zones:
  2. //
  3. // Provided by Red Hat caching-nameserver package
  4. //
  5. // ISC BIND named zone configuration for zones recommended by
  6. // RFC 1912 section 4.1 : localhost TLDs and address zones
  7. // and
  8. // (c)2007 R W Franks
  9. //
  10. // See /usr/share/doc/bind*/sample/ for example named configuration files.
  11. //
  12.  
  13. zone "localhost.localdomain" IN {
  14. type master;
  15. file "named.localhost";
  16. allow-update { none; };
  17. };
  18.  
  19. zone "localhost" IN {
  20. type master;
  21. file "named.localhost";
  22. allow-update { none; };
  23. };
  24.  
  25. 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 {
  26. type master;
  27. file "named.loopback";
  28. allow-update { none; };
  29. };
  30.  
  31. zone "1.0.0.127.in-addr.arpa" IN {
  32. type master;
  33. file "named.loopback";
  34. allow-update { none; };
  35. };


    推荐阅读