Closed RANGERBEE closed 3 years ago
Here is what I have for my DHCP config...
echo "Configuring DHCP..."
sudo rm -rf /etc/dhcp/dhcpd.conf
touch /etc/dhcp/dhcpd.conf
cat << EOF > /etc/dhcp/dhcpd.conf
log-facility local2;
default-lease-time 900;
max-lease-time 7200;
subnet ${HOST_IP%.*}.0 netmask ${NETMASK} {
option routers ${HOST_IP%.*}.1;
option subnet-mask ${NETMASK};
option domain-search "${DOMAIN_NAME}";
option domain-name-servers ${HOST_IP};
next-server ${HOST_IP};
if exists user-class and option user-class = "iPXE" {
filename "http://${HOST_IP}:8080/boot.ipxe";
} else {
filename "undionly.kpxe";
}
}
host bootstrap-0 { hardware ethernet 52:54:00:c7:04:01; fixed-address ${HOST_IP%.*}.10; option host-name "bootstrap-0.${DOMAIN_SEARCH_NAME}"; }
host master-0 { hardware ethernet 52:54:00:c7:04:02; fixed-address ${HOST_IP%.*}.20; option host-name "master-0.${DOMAIN_SEARCH_NAME}"; }
host master-1 { hardware ethernet 52:54:00:c7:04:03; fixed-address ${HOST_IP%.*}.21; option host-name "master-1.${DOMAIN_SEARCH_NAME}"; }
host master-2 { hardware ethernet 52:54:00:c7:04:04; fixed-address ${HOST_IP%.*}.22; option host-name "master-2.${DOMAIN_SEARCH_NAME}"; }
host worker-0 { hardware ethernet 52:54:00:c7:04:05; fixed-address ${HOST_IP%.*}.30; option host-name "worker-0.${DOMAIN_SEARCH_NAME}"; }
host worker-1 { hardware ethernet 52:54:00:c7:04:06; fixed-address ${HOST_IP%.*}.31; option host-name "worker-1.${DOMAIN_SEARCH_NAME}"; }
host worker-2 { hardware ethernet 52:54:00:c7:04:07; fixed-address ${HOST_IP%.*}.32; option host-name "worker-2.${DOMAIN_SEARCH_NAME}"; }
host worker-3 { hardware ethernet 52:54:00:c7:04:08; fixed-address ${HOST_IP%.*}.33; option host-name "worker-3.${DOMAIN_SEARCH_NAME}"; }
host worker-4 { hardware ethernet 52:54:00:c7:04:09; fixed-address ${HOST_IP%.*}.34; option host-name "worker-4.${DOMAIN_SEARCH_NAME}"; }
EOF
chown root:root /etc/dhcp/dhcpd.conf
chmod 644 /etc/dhcp/dhcpd.conf
# configure firewall for access
firewall-cmd --permanent --add-service=dhcp
firewall-cmd --reload
# start the service
systemctl enable --now dhcpd.service &&
systemctl start --now dhcpd.service &&
echo "Configuring DHCP... Done."
I am just stuck with the script waiting to retrieve a DHCP address for VM...
Thank you!
Could you advise as where it is waiting to pull dhcp lease from ? libvirt network or?
I am thinking of deploying dhcp locally with dhcp-server on local host.
What would you suggest for best case scenario?