#!/bin/bash
# Dhcp software installation
[ -d /etc/dhcp/dhcpd ] || yum -y install dhcp
read -p "Enter your name" localname
read -p "segment belongs to the lease of" aaa
read -p "Enter the starting pool address" the begin
read -p "Enter the ending address pool" End
read -p "Enter your gateway "HH
# modify the configuration file
CAT << END> /etc/dhcp/dhcpd.conf
the Option Domain-name" $ localname ";
the Option Domain-name-Servers 202.106.0.20,8.8.8.8;
read -p "segment belongs to the lease of" aaa
read -p "Enter the starting pool address" the begin
read -p "Enter the ending address pool" End
read -p "Enter your gateway "HH
# modify the configuration file
CAT << END> /etc/dhcp/dhcpd.conf
the Option Domain-name" $ localname ";
the Option Domain-name-Servers 202.106.0.20,8.8.8.8;
default-lease-time 600;
max-lease-time 7200;
subnet $aaa netmask 255.255.255.0 {
range $begin $end;
option routers $hh;
}
END
max-lease-time 7200;
subnet $aaa netmask 255.255.255.0 {
range $begin $end;
option routers $hh;
}
END
# Start Service
systemctl restart dhcpd
systemctl enable dhcpd && echo "successful start"
systemctl restart dhcpd
systemctl enable dhcpd && echo "successful start"