centos7搭建DNS服务器

来源:互联网 发布:帝国cms 自动刷新 编辑:程序博客网 时间:2024/05/21 09:43

在DNS服务器上



1、安装DNS服务器:bind

       

      yum -y install bind bind-utils bind-chroot#安装bind bind-utils bind-chroot

      rpm -qa |grep '^bind' #用rpm查看是否安装了bind bind-utils bind-chroot

      vim /etc/named.conf  # 修改配置文件named.conf

         listen-on port 53 { any; } #监听任何主机53端口

         allow-query {any;}          #对任意用户开放


      vim /etc/named.rfc1912.zones

                                                                        zone "hadoop.com" IN { 

                                                                                  type master;

                                                                                  file "named.hadoop.com";

                                                                                 allow-update { none; }; 

                                                                        };

                                                                        zone "20.168.192.in-addr.arpa" IN { 

                                                                                    type master;   

                                                                                    file "named.192.168.20.zone";   

                                                                                    allow-update { none; };    

                                                                        };


第二个:file "named.192.168.20.zone";根据实际情况填写.


2、正向解析文件

cd /var/named/

cp -p named.localhost named.hadoop.com  //-p 保持文件权限不变



注意 user3.hadoop.com 是DNS服务器
user3.hadoop.com. IN A 192.168.20.128  =>注意和实际IP地址的对应关系



3、反向解析文件

cp -p named.localhost named.192.168.20.zone //与实际配置文件一致




4、在客户端的 /etc/sysconfig/network-scripts/

      vim ifcfg-ens32

       追加:DNS1=192.168.20.128



5、重启网络服务:service network restart


6、启动DNS服务器并且设置开机自启

    systemctl start named.service

    systenctl enable named.service


7、尝试解析user5.hadoop.com 

      nklookup user5.hadoop.com 


遇到一些问题:

服务器端能正常解析但是客户端不能使用DNS解析

1、在/etc/resolv.conf文件中追加DNS服务器的位置

      cd /etc

      vim resolv.conf

      nameserver 192.168.20.128


2、关闭防火墙并且关闭开机自启

       systemctl stop firewalld.service#关闭防火墙

       systemctl disable firewalld.service#禁止自启动


3、关闭selinux:

         如果要永久关闭,可以修改配置文件/etc/selinux/config,将SELINU置为disabled。

 
  1. [root@rdo ~]# cat /etc/selinux/config   
  2.   
  3. # This file controls the state of SELinux on the system.  
  4. SELINUXcan take one of these three values:  
  5. #     enforcing - SELinux security policy is enforced.  
  6. #     permissive - SELinux prints warnings instead of enforcing.  
  7. #     disabled - No SELinux policy is loaded.  
  8. #SELINUX=enforcing  
  9. SELINUX=disabled  
  10. SELINUXTYPEcan take one of three two values:  
  11. #     targeted - Targeted processes are protected,  
  12. #     minimum - Modification of targeted policy. Only selected processes are protected.   
  13. #     mls - Multi Level Security protection.  
  14. SELINUXTYPE=targeted   
0 0