CentOS 6.5下配置DNS过程
CentOS 6.5下配置DNS过程
安装bind
# mount -o loop /root/Downloads/CentOS-6.5-x86_64-bin-DVD1.iso /mnt/DVD
# cd /mnt/DVD
# cd Packages
# ll | grep bind
-r--r--r-- 2 root root 4171112 Aug 28 2013 bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
-r--r--r-- 2 root root 72520 Aug 28 2013 bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
-r--r--r-- 2 root root 70696 Nov 25 2013 bind-dyndb-ldap-2.3-5.el6.x86_64.rpm
-r--r--r-- 2 root root 910676 Aug 28 2013 bind-libs-9.8.2-0.17.rc1.el6_4.6.i686.rpm
-r--r--r-- 2 root root 899540 Aug 28 2013 bind-libs-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
-r--r--r-- 2 root root 186584 Aug 28 2013 bind-utils-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
# rpm -ivh bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
# rpm -ivh bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
• 配置named.conf
key "rndc-key" {
algorithm hmac-md5;
secret "4Re7AAqoTeAWNLyZUyD1sQ==";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
options
{
// Put files that named is allowed to write in the data/ directory:
directory "/var/named"; // "Working" directory
dump-file "data/cache_dump.db";
statistics-file "data/named_stats.txt";
memstatistics-file "data/named_mem_stats.txt";
//listen-on port 53 { any; };
listen-on port 53 { any; };
//listen-on-v6 port 53 { any; };
listen-on-v6 port 53 { ::1; };
allow-query { any; };
allow-query-cache { any; };
// Enable/disable recursion - recursion yes/no;
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
};
logging
{
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view "localhost_resolver"
{
match-clients { any; };
match-destinations { any; };
recursion yes;
# all views must contain the root hints zone:
zone "." IN {
type hint;
//file "/var/named/named.ca";
file "/dev/null";
};
include "/etc/named.rfc1912.zones";
};
• 配置zone: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 "Oracle.test" IN {
type master;
file "oracle.test.zone";
allow-update { none; };
};
zone "17.168.192.in-addr.arpa" IN {
type master;
file "17.168.192.zone";
allow-update { none; };
};
正向解析文件:
# cat oracle.test.zone
$TTL 86400
@ IN SOA ns.oracle.test. root.oracle.test. (
42 ; serial
3H ; refresh
15M ; retry
1W ; expire
1D ) ; minimum
IN NS ns.oracle.test.
ns IN A 192.168.17.240
node1 IN A 192.168.17.235
node2 IN A 192.168.17.236
node1-vip IN A 192.168.17.237
node2-vip IN A 192.168.17.238
node-scan IN A 192.168.17.239
反向解析文件:
# cat 17.168.192.zone
$TTL 86400
@ IN SOA ns.oracle.test. root.oracle.test. (
1997022700 ; serial
28800 ; refresh
14400 ; retry
3600000 ; expire
86400 ) ; minimum
IN NS ns.oracle.test.
240 IN PTR ns.oracle.test.
235 IN PTR node1.oracle.test.
236 IN PTR node2.oracle.test.
237 IN PTR node1-vip.oracle.test.
238 IN PTR node2-vip.oracle.test.
239 IN PTR node-scan.oracle.test.
配置完控制文件后还要记得生成rndc-key,这里就不再赘述了。
都完成后便可以重启named服务并检查配置了:
# service named restart
# service named status
# nslookup node1
Server: 192.168.17.240
Address: 192.168.17.240#53
Name: node1.oracle.test
Address: 192.168.17.235