linux下dns主从服务器实现
主域名服务器:ns1.zdj.com,172.17.0.142
从域名服务器:ns2.zdj.com,172.17.0.37
两台服务器均能够提供 zdj.com 区域的域名解析
主域名服务器:1. ip:172.17.0.142
[root@localhost var]# vim /var/named/chroot/etc/named.rfc1912.zones ----添加下列内容
zone "zdj.com" IN {
type master;
file "zdj.com";
allow-transfer{172.17.0.37;};
};
zone "0.17.172.in-addr.arpa" IN {
type master;
file "172.17.0.zone";
allow-transfer {172.17.0.37;} ;
};
2.
[root@localhost named]# vim zdj.com --------编辑以下内容---正向解析
$TTL 1D
@ IN SOA ns1.zdj.com. root.zdj.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS ns1.zdj.com.
@ NS ns2.zdj.com.
ns1 A 172.17.0.142
ns2 A 172.17.0.37
www A 172.17.0.123
www A 172.17.0.122
www A 172.17.0.124
web CNAME www ---------别名
* A 172.17.0.252
3.
[root@localhost named]# vim 172.17.0.zone --------编辑以下内容-----反向解析
$TTL 1D
@ IN SOA ns1.zdj.com. root.zdj.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS ns1.zdj.com.
@ NS ns2.zdj.com.
142 PTR ns1.zdj.com.
37 PTR ns2.zdj.com.
123 PTR www.zdj.com.
124 PTR www.zdj.com.
122 PTR www.zdj.com.
4.
[root@localhost named]# cat /etc/resolv.conf ---------设置dns服务器设置为自己,测试用
; generated by /sbin/dhclient-script
#nameserver 8.8.8.8
nameserver 172.17.0.142
5.
[root@localhost named]# service named restart
从域名服务器: ip:172.17.0.37
1.
[root@localhost slaves]#vim /var/named/chroot/etc/named.conf
options {
listen-on port 53 { 172.17.0.37; };
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 { any; };
recursion yes;
# dnssec-enable yes;
# dnssec-validation yes;
# dnssec-lookaside auto;
/* Path to ISC DLV key */
# bindkeys-file "/etc/named.iscdlv.key";
};
2.
[root@localhost slaves]#vim /var/named/chroot/etc/named.rfc1912.zones ------------添加以下内容
zone "zdj.com" IN {
type slave;
masters {172.17.0.142;};
file "slaves/zdj.com";
};
zone "0.17.172.in-addr.arpa" IN {
type slave;
masters {172.17.0.142;};
file "slaves/172.17.0.zone";
};
3.[root@localhost slaves]#service named restart
测试机
[root@zdj ~]# vim /etc/resolv.conf
; generated by /sbin/dhclient-script
#nameserver 59.51.78.211
#nameserver 222.246.129.81
nameserver 172.17.0.142
[root@zdj ~]# host www.zdj.com
www.zdj.com has address 172.17.0.123
www.zdj.com has address 172.17.0.124
www.zdj.com has address 172.17.0.122
[root@zdj ~]# host 172.17.0.122
122.0.17.172.in-addr.arpa domain name pointer www.zdj.com
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。