自动化安装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
如对您有帮助,支持下呗!
微信
支付宝