1、  检验dns是否安装
# rpm –qa |grep bind
# rpm –qa |grep caching-nameserver
  
2、 DNS3个主要的配置文件:
l         /etc/named.conf
l         /var/named/chroot/var/named/正向区域文件
l         /var/named/chroot/var/named/反向区域文件
 
假设创建一个DNS服务器,域名为yxr.com,主机名为redhatDNS服务器IP地址为192.168.100.1,网络为192.168.100.1/24。同时创建正向和反向查找区域,正向解析区域为yxr.com.zone,反向区域文件为100.168.192.in-addr.arpa.zone。下面是3个主要配置文件的配置(更改部分均为突出颜色显示):
 
配置named.conf主配置文件
//
// named.conf for Red Hat caching-nameserver
//
 
options {
    directory "/var/named";
    dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
    /*
     * If there is a firewall between you and nameservers you want
     * to talk to, you might need to uncomment the query-source
     * directive below.  Previous versions of BIND always asked
     * questions using port 53, but BIND 8.1 uses an unprivileged
     * port by default.
     */
     // query-source address * port 53;
};
 
//
// a caching only nameserver config
//
controls {
    inet 192.168.100.1 allow { localhost; } keys { rndckey; };
};
 
zone "." IN {
    type hint;
    file "named.ca";
};
 
zone "localdomain" IN {
    type master;
    file "localdomain.zone";
    allow-update { none; };
};
 
zone "localhost" IN {
    type master;
    file "localhost.zone";
    allow-update { none; };
};
 
zone "yxr.com" IN{
    type master;
    file "yxr.com.zone";
    allow-update { none; };
};
 
zone "100.168.192.in-addr.arpa" IN {
    type master;
    file "100.168.192.in-addr.arpa.zone";
    allow-update { none; };
};
 
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.ip6.arpa" IN {
        type master;
    file "named.ip6.local";
    allow-update { none; };
};
 
zone "255.in-addr.arpa" IN {
    type master;
    file "named.broadcast";
    allow-update { none; };
};
 
zone "0.in-addr.arpa" IN {
    type master;
    file "named.zero";
    allow-update { none; };
};
 
include "/etc/rndc.key";
 
创建并配置yxr.com.zone正向解析文件$TTL    86400
@       IN SOA  redhat.yxr.com.   root.yxr.com. (
                2009100101 ; serial (d. adams)
                28800      ; refresh
                14400      ; retry
                3600000    ; expiry
                86400 )    ; minimum
 
@          IN NS         redhat.yxr.com.
redhat    IN A        192.168.100.1
www       IN A        192.168.100.1
mail      IN CNAME    redhat.yxr.com.
yxr.com.  IN MX 10    mail.yxr.com.
 
创建并配置100.168.192.in-addr.arpa.zone反向解析文件
$TTL    86400
@       IN SOA  redhat.yxr.com. root.yxr.com. (
                2009100101 ; serial (d. adams)
                28800      ; refresh
                14400      ; retry
                3600000    ; expiry
                86400 )    ; minimum
 
@         IN NS       redhat.yxr.com.
1         IN PTR      redhat.yxr.com.
1         IN PTR      www.yxr.com.
1         IN PTR      redhat.yxr.com.
 
 
3、 除了需要对以上3个配置文件进行配置外,在DNS服务器上还需要同时进行如下配置。
(1)       设置IP地址
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
  
# service network restart
 
(2)       DNS客户端设置
# vi /etc/resolv.conf
  
(3)       添加主机记录
 
 
4、 启动DNS服务
# service named start
然后通过
# tail /var/log/messages
查看日志文件提示信息
 
 
在客户端上使用nslookup进行测试:
 
测试成功,表示DNS正向和反向均正常解析