The basic things are all there. You need to combine the things and then click OK.
#! /Bin/bash
Yum-y install DHCP
\ CP/usr/share/doc/dhcp-3.0.5/DHCPD. conf. Sample/etc/DHCPD. conf
Read-P "Enter the network segment" WD
Read-R "Enter the subnet mask" zwym
Sed-I-r "/^ subnet/S/([0-9] {0, 2} | 1 [0-9] {2} | 2 [0-4] [0-9] | 25 [0-5]) \.) {3} ([0-9] {0, 2} | 1 [0-9] {2} | 2 [0-4] [0-9] | 25 [0-5 ]) /$ WD/"/etc/DHCPD. conf
Sed-I-r "/^ subnet/S/([0-9] {0, 2} | 1 [0-9] {2} | 2 [0-4] [0-9] | 25 [0-5]) \.) {3} ([0-9] {0, 2} | 1 [0-9] {2} | 2 [0-4] [0-9] | 25 [0-5 ]) /$ zwym/2 "/etc/DHCPD. conf
Sed-I '2 a option domain-name-servers 8.8.8.8; '/etc/DHCPD. conf
Sed-I '2 a max-lease-time 7200; '/etc/DHCPD. conf
Sed-I '2 a default-lease-time 600;'/etc/DHCPD. conf
Sed-I '/Default Gateway/, + 24d'/etc/DHCPD. conf
Sed-ri'/^ subnet/A \ toption routers 192.168.1.254; '/etc/DHCPD. conf
Sed-ri '/^ subnet/A \ toption subnet-mask limit 255.0;'/etc/DHCPD. conf
Sed-ri '/^ subnet/A \ trange 192.168.1.100 192.168.1.200;'/etc/DHCPD. conf
Sed-ri '/^ subnet/A \ trange 192.168.1.50 192.168.1.60;'/etc/DHCPD. conf
Service DHCPD start
Optimization
Sed-I's/dhcpdargs = "eth0"/'/etc/sysconfig/DHCPD
Enable DHCP relay
Sed-I '/net. ipv4.ip _ forward/S/0/1/'/etc/sysctl. conf
Sysctl-P
Echo "dhcrelayargs = \" eth0 \ "">/etc/sysconfig/dhcrelay
Echo "dhcpservers = \" 192.168.1.254 \ "">/etc/sysconfig/dhcrelay
Service dhcrelay start
Or
Sed-I '/dhcrelayargs =/S/""/"eth0"/'/etc/sysconfig/dhcrelay
Sed-I '/dhcpservers =/S/""/"192.168.1.254"/'/etc/sysconfig/dhcrelay
Sed-I '/dhcrelayargs =/S/""/"eth0"/'/etc/sysconfig/dhcrelay
Client check
Dhclient-D eth0
Check DHCP allocation information on the server
/Var/lib/DHCPD. Leases
Client View
/Var/lib/dhclinet/dhclient. Leases
Automatically deploy DHCP service scripts