1、卸载bind
[root@mail ~]# rpm -e bind-utils
2、安装bind97-utils bind97-libs bind97
[root@mail ~]# yum install bind97 bind97-utils #bind97-libs依赖于utils
3、启动dns服务
[root@mail ~]# service named start
4、编写配置文件和区域数据文件
[root@mail ~]# vim /etc/named.conf
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {
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";
allow-query { localhost; };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
[root@mail ~]# vim /etc/named.rfc1912.zones
在里面添加下面的内容:
zone "lsq.com" IN {
type master;
file "lsq.com.zone";
allow-update { none; };
allow-transfer { none; };
};
zone "25.16.172.in-addr.arpa" IN {
type master;
file "172.16.25.zone";
allow-update { none; };
allow-transfer { none; };
};
配置区域数据文件:
[root@mail ~]# cd /var/named
[root@mail named]# vim lsq.com.zone
$TTL 600
@ IN SOA ns.lsq.com. admin.lsq.com. (
2013050401
2H
10M
3D
1D )
IN NS ns
IN MX 10 mail
ns IN A 172.16.25.1
mail IN A 172.16.25.1
[root@mail named]# vim 172.16.25.zone
$TTL 600
@ IN SOA ns.lsq.com. admin.lsq.com. (
2013050401
2H
10M
3D
1D )
IN NS ns.lsq.com.
1 IN PTR ns.lsq.com.
1 IN PTR mail.lsq.com.
5、检查语法错误并重启服务
[root@mail named]# named-checkconf
[root@mail named]# named-checkzone "lsq.com" lsq.com.zone
zone lsq.com/IN: loaded serial 2013050401
OK
[root@mail named]# named-checkzone "25.16.172.in-addr.arpa" 172.16.25.zone
zone 25.16.172.in-addr.arpa/IN: loaded serial 2013050401
OK
[root@mail named]# chgrp named lsq.com.zone 172.16.25.zone [root@mail named]# chmod 640 lsq.com.zone 172.16.25.zone
[root@mail named]# service named restart
Stopping named: [ OK ]
Starting named: [ OK ]
6、解析A记录
[root@mail named]# dig -t A mail.lsq.com @172.16.25.1
; <<>> DiG 9.7.0-P2-RedHat-9.7.0-6.P2.el5_7.4 <<>> -t A mail.lsq.com @172.16.25.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;mail.lsq.com. IN A
;; ANSWER SECTION:
mail.lsq.com. 600 IN A 172.16.25.1
;; AUTHORITY SECTION:
lsq.com. 600 IN NS ns.lsq.com.
;; ADDITIONAL SECTION:
ns.lsq.com. 600 IN A 172.16.25.1
;; Query time: 48 msec
;; SERVER: 172.16.25.1#53(172.16.25.1)
;; WHEN: Sun Mar 31 02:19:09 2013
;; MSG SIZE rcvd: 79
解析反向记录
[root@mail named]# dig -x 172.16.25.1 @172.16.25.1
; <<>> DiG 9.7.0-P2-RedHat-9.7.0-6.P2.el5_7.4 <<>> -x 172.16.25.1 @172.16.25.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;1.25.16.172.in-addr.arpa. IN PTR
;; ANSWER SECTION:
1.25.16.172.in-addr.arpa. 600 IN PTR ns.lsq.com.
1.25.16.172.in-addr.arpa. 600 IN PTR mail.lsq.com.
;; AUTHORITY SECTION:
25.16.172.in-addr.arpa. 600 IN NS ns.lsq.com.
;; ADDITIONAL SECTION:
ns.lsq.com. 600 IN A 172.16.25.1
;; Query time: 1 msec
;; SERVER: 172.16.25.1#53(172.16.25.1)
;; WHEN: Sun Mar 31 02:20:08 2013
;; MSG SIZE rcvd: 115
[root@mail named]#