#!/bin/bash
#安装dhcp软件
[ -d /etc/dhcp/dhcpd ] || yum -y install dhcp
read -p "输入你的域名" localname
read -p "属于对外出租的网段" aaa
read -p "输入起始地址池地址" begin
read -p "输入结尾地址池地址" end
read -p "输入你的网关" hh
#修改配置文件
cat << END > /etc/dhcp/dhcpd.conf
option domain-name "$localname";
option domain-name-servers 202.106.0.20,8.8.8.8;
read -p "属于对外出租的网段" aaa
read -p "输入起始地址池地址" begin
read -p "输入结尾地址池地址" end
read -p "输入你的网关" hh
#修改配置文件
cat << END > /etc/dhcp/dhcpd.conf
option domain-name "$localname";
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
#启动服务
systemctl restart dhcpd
systemctl enable dhcpd && echo "启动成功"
systemctl restart dhcpd
systemctl enable dhcpd && echo "启动成功"