10.0.16.36为普通PC IP
10.0.16.180为CentOS服务器 IP
安装
yum install -y bind bind-chroot bind-utis
主要配置文件
[root@localhost named]# vim /etc/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 {
listen-on port 53 { any; };//开启监听端口53并接受任意IP连接
#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";
allow-query { 0.0.0.0/0; }; //允许任意IP查询
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
创建正向反向区域
[root@localhost named]# vim /etc/named.rfc1912.zones
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
// and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
// (c)2007 R W Franks
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
zone "yytest.com" IN {
type master;
file "named.yytest.com";
allow-update { none; };
};
zone "16.0.10.in-addr.arpa" IN {
type master;
file "10.0.16.arpa";
allow-update { none; };
};
配置正向文件明细
[root@localhost named]# vim /var/named/named.yytest.com
$TTL 1D
@ IN SOA yytest.com. rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
xd IN A 10.0.16.36
配置反向文件明细
[root@localhost named]# vim /var/named/10.0.16.arpa
$TTL 1D
@ IN SOA yytest.com. rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
AAAA ::1
36 PTR xd.
需要注意/var/named/named.yytest.com与/var/named/10.0.16.arpa两个文件所属组应该是named而不是root,使用chgrp named 修改
修改DNS文件
[root@localhost named]# vim /etc/resolv.conf
nameserver 10.0.16.180
测试
[root@localhost named]# nslookup
> xd.yytest.com
Server: 10.0.16.180
Address: 10.0.16.180#53
Name: xd.yytest.com
Address: 10.0.16.36
> 10.0.16.36
Server: 10.0.16.180
Address: 10.0.16.180#53
36.16.0.10.in-addr.arpa name = xd.
>
查看是哪个DNS服务器
[root@localhost named]# dig -t ns xd.yytest.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6_6.3 <<>> -t ns xd.yytest.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21500
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;xd.yytest.com. IN NS
;; AUTHORITY SECTION:
yytest.com. 10800 IN SOA yytest.com. rname.invalid. 0 86400 3600 604800 10800
;; Query time: 0 msec
;; SERVER: 10.0.16.180#53(10.0.16.180)
;; WHEN: Mon Aug 10 20:24:09 2015
;; MSG SIZE rcvd: 80