码迷,mamicode.com
首页 > 系统相关 > 详细

shell脚本之dhcp的配置

时间:2014-11-27 18:58:45      阅读:275      评论:0      收藏:0      [点我收藏+]

标签:continue   gateway   please   

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


shell脚本之dhcp的配置

标签:continue   gateway   please   

原文地址:http://mengwumian.blog.51cto.com/9562947/1583118

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!