DNS master-slave domain name resolution server experiment of Linux network

Configure the primary domain name server

Modify the zone configuration file of the primary domain name server, modify the forward and reverse zone configuration

vim /etc/named.rfc1912.zones
zone "benet.com" IN {
    
    
		type master;                  				●类型为主区域
		file "benet.com.zone";
		allow-transfer {
    
     192.168.80.11; };  		●允许从服务器下载正向区域数据,这里添从服务器的IP地址
};

zone "80.168.192.in-addr.arpa" IN {
    
    			
        type master;
        file "benet.com.zone.local";		
        allow-transfer {
    
     192.168.80.11; };
};

Configure slave domain name server

Modify the master configuration file of the slave domain name server

yum install -y bind
vim /etc/named.conf
options {
    
    
    listen-on port 53 {
    
     192.168.80.11; };	●监听53端口,ip地址使用提供服务的本地IP即可,也可用any代表所有
#    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";	
    recursing-file  "/var/named/data/named.recursing";
    secroots-file   "/var/named/data/named.secroots";
    allow-query     {
    
     any; }; 				●允许使用本DNS解析服务的网段,也可用any代表所有
	……
}

Insert picture description here
Insert picture description here

Modify the zone configuration file from the domain name server, add positive and negative zone configuration

vim /etc/named.rfc1912.zone
zone "benet.com" IN {
    
    
		type slave;							●类型为从区域
		masters {
    
     192.168.80.10; };			●指定主服务器的IP地址
		file "slaves/benet.com.zone";   	●下载的区域数据文件保存到slaves/目录下
};
zone "80.168.192.in-addr.arpa" IN {
    
    	
        type slave;
		masters {
    
     192.168.80.10; };
        file "slaves/benet.com.zone.local";
};

Insert picture description here

result

Both the master and slave restart the service, and check whether the area data file has been downloaded successfully

systemctl restart named
ls -l /var/named/slaves/

Insert picture description here

Add the slave DNS server address in the domain name resolution configuration file of the client

echo "nameserver 192.168.80.11" >> /etc/resolv.conf
或
vim /etc/resolv.conf

Insert picture description here

Do not stop the service of the main server for testing

host 192.168.80.200
nslookup 192.168.80.200

Insert picture description here

Stop the service of the main server and simulate the failure of the main server

systemctl stop named
host 192.168.80.200
nslookup 192.168.80.200

Insert picture description here

Guess you like

Origin blog.csdn.net/m0_53497201/article/details/114243797