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

 

相关文章:

  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
  • 2021-10-04
  • 2021-08-29
  • 2022-12-23
  • 2021-04-04
  • 2021-07-28
猜你喜欢
  • 2022-01-13
  • 2021-10-19
  • 2021-10-29
  • 2021-11-20
  • 2021-11-12
  • 2021-09-09
  • 2021-09-02
相关资源
相似解决方案