自动化安装DHCP配置脚本
Posted Louis He
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自动化安装DHCP配置脚本相关的知识,希望对你有一定的参考价值。
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配置脚本的主要内容,如果未能解决你的问题,请参考以下文章