#!/bin/bash
Echo ' The script is install DHCPD server '
Read-p "Please insert RHEL5-CD-cdrom and enter to next:" AA
mount/dev/cdrom/media/&>/dev/null
rpm-uvh/media/server/dhcp-* &>/dev/null
echo "Please configure IP address for this machine"
Read-p "Please enter IP address:" IP
Read-p "Please enter the Mask:" Ip_mask
macaddr=$ (ifconfig eth0 |grep Eth0|awk ' {print $} ')
Cat >/etc/sysconfig/network-scripts/ifcfg-eth0 <<eof
Device=eth0
Onboot=yes
Bootproto=static
Ipaddr= $ip
netmask= $ip _mask
Hwaddr= $MACADDR
Eof
echo "Enabling new configured IP address for you"
Ifdown eth0;ifup eth0
echo "IP address already in effect"
Read-p "Configure the network segment for DHCP:" Dhcp_net
Read-p "Please configure the Mask for DHCP:" Dhcp_mask
Read-p "Configure your gateway for DHCP:" DHCP_GW
Read-p "Please assign the start IP to DHCP configuration:" Dhcp_bigin
Read-p "Configure end IP for DHCP:" Dhcp_over
The configuration file for cat >/etc/dhcpd.conf <<eof//DHCP3 is installed by default in/etc, and DHCP4 is installed under/ETC/DHCP, paying attention to its path
Ddns-update-style Interim;
Ignore client-updates;
Subnet $dhcp _net netmask $dhcp _mask {
option Routers $DHCP _GW;
Option Subnet-mask $dhcp _mask;
Range $dhcp _bigin $dhcp _over;
Default-lease-time 21600;
Max-lease-time 43200;
}
Eof
Service DHCPD Start &>/dev/null
NETSTAT-ANPL |grep:67
This article is from the "Dragon Love Xue qi" blog, please make sure to keep this source http://dragon123.blog.51cto.com/9152073/1583486
Script implementation easy to configure Dhcp-server