shell腳本之dhcp的配置

rpm -q dhcp &> /dev/nulldom

if [ $? -ne 0 ]ide

thenspa

yum -y install dhcprest

echo "router

ddns-update-style interim;server

ignore client-updates;dns

option domain-name-servers      192.168.1.1;ip

default-lease-time 21600;input

max-lease-time 43200;it


" > /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

相關文章
相關標籤/搜索