码迷,mamicode.com
首页 > 系统相关 > 详细

shell构建正向dns

时间:2019-08-24 16:50:27      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:star   com   dev   输入   服务   cto   clean   roo   ase   

#!/bin/bash
#挂载yum仓库

read -p "请输入你的挂载点: " dir
echo "正在挂载光盘..."
mount | grep -q "/dev/sr0" && umount /dev/sr0
[ -d $dir ] || mkdir $dir
mount /dev/sr0 $dir &> /dev/null

echo "正在修改repo文件..."
cd /etc/yum.repos.d/
[ -d bak ] || mkdir bak
mv *.repo bak

cat << END > local.repo
[xxx]
name=xxx
baseurl=file://$dir
enabled=1
gpgcheck=0
END

echo "正在清除yum缓存..."
yum clean all &> /dev/null

echo "正在建立yum缓存..."
yum makecache &> /dev/null

[ -d $dir/Packages ] && echo "yum构建成功"

#安装bind
echo "正在检测本机是否安装bind..."
if [ $(rpm -q bind ) = "bind-9.9.4-50.el7.x86_64" ] &> /dev/null
then echo "bind已经安装"
else
echo "将要安装bind"
yum -y install bind &> /dev/null
if [ $(rpm -q bind ) = "bind-9.9.4-50.el7.x86_64" ] &> /dev/null
then echo "bind安装完成 "
fi
fi

#修改主配置文件

read -p "请输入你的域名(例crushlinux.com):" abcc
read -p "请输入本机ip地址:" ipaddress

cat << END > /etc/named.conf

options {
directory "/var/named";
};

zone "$abcc" IN {
type master;
file "$abcc.zheng";
};
END

cat << END > /var/named/$abcc.zheng
\$TTL 86400
@ IN SOA $abcc. root.$abcc. (
345343
3H
15M
1W
1D
)
IN NS ns1.$abcc.
IN MX 10 mail.$abcc.
ns1 IN A $ipaddress
www IN A 192.168.12.111
study IN A 192.168.12.112
END

chgrp named /var/named/$abcc.zheng

cat << END >> /etc/resolv.conf
nameserver $ipaddress
END

cat << END > /etc/hosts
$ipaddress ns1.$abcc.
END
#启动dns服务
systemctl start named
systemctl restart named &> /dev/null
systemctl enable named &> /dev/null
systemctl status named | grep running &> /dev/null && echo "dns服务已启动"

 

shell构建正向dns

标签:star   com   dev   输入   服务   cto   clean   roo   ase   

原文地址:https://www.cnblogs.com/zhiyuan-yu/p/11405059.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!