linux下dns主从搭建,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

你可能感兴趣的:(linux下dns主从搭建)