shell腳本之dhcp的配置

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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章