码迷,mamicode.com
首页 > 其他好文 > 详细

自动化安装DHCP配置脚本

时间:2017-11-05 23:26:10      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:try   name   please   add   dhcp   osi   war   style   was   

DHCP配置脚本:
#!/bin/sh
NET=192.168.6.0
MASK=255.255.255.0
RANGE="192.168.6.50 192.168.6.100"
DNS=114.114.114.114
DOMAIN_NAME="example.com"
ROUTER=192.168.6.254
test_yum(){
yum list dhcp >/dev/null 2&>1
if [ $? -ne 0 ];then
echo
echo "There was an error to connect to Yum repository."
echo "Please verify your yum repository settings and try again."
echo
exit
fi
}
test_conf(){
if [ -f /etc/dhcp/dhcp.conf ];then
mv /etc/dhcp/dhcp.conf /etc/dhcp/dhcp.conf.bak
fi
}
create_conf(){
cat >/etc/dhcp/dhcp.conf <<EOF
default-lease-time 600;
max-lease-time 7200;
subnet $NET netmask $MASK{
range $RANGE;
option domain-name-servers $DNS;
option domain-name "$DOMAIN_NAME";
option routers $ROUTER;
}
host passacaglia {
hardware ethernet 0:0:c0:5d:bd:95;
fixed-address 192.168.6.133;
EOF
}
rpm -q dhcp >/dev/null 2&>1
if [ $? -ge 0 ];then
test_yum
yum -y install dhcp >/dev/null 2&>1
fi
test_conf
create_conf
service dhcpd start
chkconfig dhcpd on

自动化安装DHCP配置脚本

标签:try   name   please   add   dhcp   osi   war   style   was   

原文地址:http://www.cnblogs.com/Dev0ps/p/7789112.html

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