Linux平台配置DNS分离解析服务器

配置文件地址
函数库地址

#!/bin/bash
#AUTHOR:AN
#VERSION:1.0.0
#DATE:2019-06-03
#MODIFY:
#FUNCTION:实现DNS分离解析

#加载配置文件
source /cloud_nsd/conf/dns.conf
#加载函数库
if [ -f "$Script_Path/myfunction.lib" ];then
 	source $Script_Path/myfunction.lib 
else
	echo -e "\033[31m函数库不存在\033[0m"
	exit $NOEXIST
fi

##############################################################
#DNS主配置文件
SPLIT_CONF(){
	YUM "${Soft_Packet[*]}"
	[ ! -f $Dns_Conf.bak ] && cp $Dns_Conf $Dns_Conf.bak		#备份配置文件
	> $Dns_Conf
	cat >> $Dns_Conf << EOF
options {
	directory "$Addr_Path";			
};

view "client1" {
	match-clients {$Client1;};
	zone "$Domain_Name" IN {
		type master;
		file "$Addr_Name1";
	};
};

view "client2" {
	match-clients {$Client2;};
	zone "$Domain_Name" IN {
		type master;
		file "$Addr_Name2";
	};
};
EOF
}

#建立地址库文件
ADDR_CONF1(){
	cp -p $Addr_Path/named.localhost $Addr_Name1
	sed -i '8,10d' $Addr_Name1
	cat >> $Addr_Name1 << EOF
${Domain_Name}.	NS	$HOSTNAME
DNS 		A	$Dns_Server
www		A	$Proxy1
EOF
	
}

ADDR_CONF2(){
	cp -p $Addr_Path/named.localhost $Addr_Name2
	sed -i '8,10d' $Addr_Name2
	cat >> $Addr_Name2 << EOF
${Domain_Name}.	NS	$HOSTNAME
DNS 		A	$Dns_Server
www		A	$Proxy2
EOF
}

#############################主程序#############################
SPLIT_CONF
ADDR_CONF1 && ADDR_CONF2
STR_SVC named && CA_SERVICE named

你可能感兴趣的:(Shell)