#/bin/bash
#安装依赖
yum install -y dhcp &> /dev/null
#DHCP配置 这部分需要手动输入
dhcpconf="/etc/dhcp/dhcpd.conf"
read -p "网段地址[example 172.16.0.0]:" subnet
read -p "子网掩码[example 255.255.0.0]:" netmask
read -p "IP池头地址[example 172.16.0.50]:" nstart
read -p "IP池尾地址[example 172.16.0.200]:" nend
read -p "网关地址[example 172.16.0.1]:" gateway
read -p "本机地址:" localnet
cat << EOF >> ${dhcpconf}
subnet ${subnet} netmask ${netmask} {
range ${nstart} ${nend};
option domain-name-servers 8.8.8.8;
option routers ${gateway};
default-lease-time 600;
max-lease-time 7200;
next-server ${localnet};
filename "pxelinux.0";
}
EOF
systemctl start dhcpd
systemctl enable dhcpd &> /dev/null
systemctl status dhcpd
Shell—DHCP一键部署
最新推荐文章于 2023-01-11 16:22:05 发布