rpm -q dhcp &> /dev/null
if [ $? -ne 0 ]
then
yum -y install dhcp
echo "
ddns-update-style interim;
ignore client-updates;
option domain-name-servers 192.168.1.1;
default-lease-time 21600;
max-lease-time 43200;
" > /etc/dhcpd.conf
fi
while true
do
read -p "please input network:" network
grep $network /etc/dhcpd.conf &> /dev/null
if [ $? -eq 0 ];then
read -p "continue to do?(yes/no)" yn
if [ $yn = yes ];then
continue
else
break
fi
fi
read -p "please input gateway:" gateway
read -p "please input netmask:" netmask
read -p "please input start_ip:" start_ip
read -p "please input end_ip:" end_ip
read -p "Are you sure?(yes/no)" yn
if [ $yn != yes ];then
continue
fi
echo "
subnet $network netmask $netmask {
option routers $gateway;
option subnet-mask $netmask;
range dynamic-bootp $start_ip $end_ip;
}
" >> /etc/dhcpd.conf
read -p "contine to do?(yes/no)" yn
if [ $yn = no ];then
break
fi
done
service dhcpd restart
原文地址:http://mengwumian.blog.51cto.com/9562947/1583118