-------------随便写的----------------
安装YUM
#!/bin/bash
#创建本地yum
a=/media
echo "挂载光盘..."
[ -d /media/Packages ] || mount /dev/sr0 $a &> /dev/null
echo "建立yum文件..."
cd /etc/yum.repos.d/
echo "
[xxx]
name=xxx
baseurl=file://$a
enabled=1
gpgcheck=0
" > local.repo
echo "重建yum缓存..."
yum -y clean all &> /dev/null && yum makecache &> /dev/null
===============================
安装DHCP
#!/bin/bash
#create dhcp
yum -y install dhcp
cat << EOF > /etc/dhcp/dhcpd.conf
option domain-name "yxhyxh";
option domain-name-servers 202.106.0.20;
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.50.0 netmask 255.255.255.0 {
range 192.168.50.50 192.168.50.121;
option routers 192.168.50.2;
next-server 192.168.50.125;
filename "pxelinux.0";
}
EOF
systemctl start dhcpd
===========================
安装DNS
#!/bin/bash
#create DNS
read -p "请输入你想要的域名" com
#安装BIND软件包
yum -y install bind
#修改配置文件
cat << EOF > /etc/named.conf
options {
directory "/var/named";
};
zone "$com" IN {
type master;
file "yuan.zheng";
};
EOF
#修改正向区域数据文件
cat << EOF >/var/named/yuan.zheng
\$TTL 1D
@ IN SOA $com. admin.$com. (
123
1D
1H
1W
3H
)
IN NS ns1.$com.
ns1 IN A 192.168.50.125
www IN A 192.168.50.125
EOF
#启动服务
systemctl start named
#检查是否成功开启服务
q=$(systemctl status named | grep "(running)" | wc -l )
if [ $q = 1 ]
then
echo "服务已启动"
else
echo "服务启动失败,请查错"
fi