我的环境是
192.168.1.130 主DNS
192.168.1.112 从DNS
DNS 的安装包有bind bind-libs bind-utils
安装DNS
# yum -y install bind
修改主配置文件,主要修改如下
#vim /etc/named.conf
options {
// listen-on port 53 { 127.0.0.1; };
// 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 { localhost; };
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";
};
定义一个正向域名
# vim /etc/named.rfc1912.zones
zone "shise.com" IN {
type master;
file "shise.com";
};
添加域
# vim /var/named/shise.com
$TTL 86400
$ORIGIN shise.com.
@ IN SOA ns1.shise.com. admin.shise.com (
2015122601 #序列号
1H #刷新时间
5M #重试时间
7D #过期时间
1D ) #否定答案的TTL值
IN NS ns1
IN NS ns2
IN MX 10 mx1
IN MX 20 mx2
ns1 IN A 192.168.1.130
ns2 IN A 192.168.1.112
mx1 IN A 192.168.1.130
mx2 IN A 192.168.1.113
www IN A 192.168.1.130
ftp IN CNAME WWW
这样一个正向解析域就定义好了改权限属组 启动DNS 测试
#chmod 640 shise.com
#chown :named shise.com
# service named start
# dig -t A www.shise.com @192.168.1.130
定义一个反向域名
# vim /etc/named.rfc1912.zones
zone "1.168.192.in-addr.arpa" IN {
type master;
file "192.168.1.zone";
};
添加反向域
# vim /var/named/192.168.1.zone
$TTL 86400
$ORIGIN 1.168.192.in-addr.arpa.
@ IN SOA ns1.shise.com. admin.shise.com. (
2015122601
1H
5M
7D
1D )
IN NS ns1.shise.com.
IN NS ns2.shise.com.
130 IN PTR ns1.shise.com.
112 IN PTR ns2.shise.com.
130 IN PTR mx1.shise.com.
113 IN PTR mx2.shise.com.
130 IN PTR www.shise.com.
重启服务测试
# chmod 640 192.168.1.zone
# chown :named 192.168.1.zone
# service named restart
# dig -x 192.168.1.130 @192.168.1.130
定义从服务器(192.168.1.112)
# vim /etc/named.conf 修改和主DNS一样
# vim /etc/named.rfc1912.zones
zone "shise.com" IN {
type slave;
masters { 192.168.1.130; };
file "slaves/shise.com";
};
zone "1.168.192.in-addr.arpa" IN {
type slave;
masters { 192.168.1.130; };
file "slaves/192.168.1.zone";
};
重启服务查看日志
#service named restart
#tail /var/log/messages
原创文章,作者:十色,如若转载,请注明出处:http://www.178linux.com/10561