RedHat CentOS搭建DNS服务器反向解析详细步骤

一.安装相关软件包:为保证顺利进行请按步骤先删除再重新安装所有软件包

[root@server ~]# rpm -qa | grep bind     //查看bind相关软件包
[root@server ~]# rpm -e `rpm -qa | grep bind` --nodeps   //删除相关软件包
[root@server ~]# mount /dev/cdrom /media/    //将系统光盘挂载到/media/
[root@server media]# cd /media/Server/     //进入/media/Server/目录(如果是CentOS系统则进入/media/CentOS/目录)
[root@server Server]# rpm -vih bind-*     //再次安装相关软件包
[root@server Server]# rpm -vih caching-nameserver-9.3.3-7.el5.i386.rpm //在CentOS中软件包名称有所不一样所以要巧用Tab补全
[root@server Server]# service named start     //重启named服务

二.修改主配置文件
[root@server Server]# cd /var/named/chroot/etc/    //进入/var/named/chroot/etc/目录
[root@server etc]# vim named.caching-nameserver.conf   //修改主配置文件
----------------------------------------------------------------------
options {
        listen-on port 53 { any; };      //修改为any
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        query-source    port 53;
        query-source-v6 port 53;
        allow-query     { any; };      //修改为any
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
view localhost_resolver {
        match-clients      { any; };      //修改为any
        match-destinations { any; };     //修改为any
        recursion yes;
        include "/etc/named.rfc1912.zones";
};
----------------------------------------------------------------------
################################################################
如果前面已经做好正向解析那么我们可以直接从这里开始
三.修改主机配置文件的扩展文件
[root@localhost ~]# cd /var/named/chroot/etc/    //进入/var/named/chroot/etc/目录
[root@server etc]# vim named.rfc1912.zones    //修改主机配置文件的扩展名;在最后一行添加如下
----------------------------------------------------------------------
zone "1.168.192.in-addr.arpa" IN {     //将你的主机IP地址前三位反写
        type master;
        file "192.168.1.rev";
};
---------------------------------------------------------------------

--------------------------------------------------------------------
[root@server named]# bind-chroot-admin -s    //自动完成组和权限设置(在CentOS中可能会提示/usr/bin/find: /var/log/named.log: 没有那个文件或目录)
[root@server named]# service named restart    //重启named服务

五.测试验证
为了验证成功最好修改本地DNS,将服务器改为自己的IP
vi /etc/resolv.conf
nameserver 192.168.1.2  
:wq   //保存退出   
[root@localhost named]# host 192.168.1.2    //在本机验证解析成功

C:\Documents and Settings\Administrator>nslookup   //远端验证解析成功
*** Can't find server name for address 219.244.93.2: Non-existent domain
*** Default servers are not available
Default Server: UnKnown
Address: 219.244.93.2      //本来我的DNS为219.244.93.2

> server 192.168.1.2      //更改解析主机
Default Server: [192.168.1.2]
Address: 192.168.1.2

相关推荐