shell脚本一键部署——DNS正向解析

DNS正向解析

#!/bin/bash
#配置正向解析 #安装bind软件包 cd ~ yum -y install bind read -p "请输入想要解析的域名,譬如(www.baidu.com): " a b=`echo $a | awk -F ‘.‘ ‘BEGIN{OFS="."}{$2=$2;print $2,$3}‘` c=`ifconfig | grep "inet" | awk ‘NR==1 {print $2}‘` #修改主配置文件 sed -i ‘s/127.0.0.1/any/‘ /etc/named.conf sed -i ‘s/localhost/any/‘ /etc/named.conf sed -i ‘14d‘ /etc/named.conf #修改区域配置文件 sed -i ‘18,50d‘ /etc/named.rfc1912.zones sed -i ‘s/localhost.localdomain/‘$b‘/‘ /etc/named.rfc1912.zones sed -i ‘s/named.localhost/‘$b‘.zone/‘ /etc/named.rfc1912.zones #修改区域数据配置文件 #备份区域数据配置文件 cd /var/named cp -p named.localhost $b.zone sed -i ‘s/@/‘$b‘./2‘ /var/named/$b.zone sed -i ‘s/rname.invalid./admin.abc.com./‘ /var/named/$b.zone sed -i ‘8s/@/‘$b‘./‘ /var/named/$b.zone sed -i ‘s/127.0.0.1/‘$c‘/‘ /var/named/$b.zone sed -i ‘10c www IN A ‘$c‘‘ /var/named/$b.zone #启动服务,关闭防火墙 systemctl stop firewalld setenforce 0 systemctl start named systemctl restart named #named -u named #如果服务启动卡住,可以执行下面命令解决 #rndc-confgen -r /dev/urandom -a #在客户端的域名解析配置文件中添加DNS服务器地址 sed -i ‘2c nameserver ‘$c‘‘ /etc/resolv.conf

shell脚本一键部署——DNS正向解析  

shell脚本一键部署——DNS正向解析

上一篇:Shell条件判断(2)- 文件权限


下一篇:Mac OS 无法启动如何备份出重要的资料