#!/bin/bash
#zxs
read -p "域名" a
read -p "定义地址池" b
read -p "默认网关" c
read -p "网段" d
#安装dhcp
rpm -q dhcp="dhcp-4.2.5-58.el7.centos.x86_64" || yum -y install dhcp >> /dev/null
echo "安装"
#配置
cat << EOF > /etc/dhcp/dhcpd.conf
option domain-name "$a";
option domain-name-servers 202.106.0.20;
default-lease-time 21600;
max-lease-time 43200;
subnet $d netmask 255.255.255.0 {
range $b;
option routers $c;
}
EOF
systemctl stop firewalld
iptables -F
setenforce 0
systemctl restart dhcpd
if [ $? -eq 0 ]
then
echo "ok"
else
echo "重做"
fi