3. DHCP Configuration
To enable management of DHCP by cobbler change the following setting in
/etc/cobbler/settings
:
manage_dhcp: 1
and restart the cobblerd
service.
When you run cobbler sync
, cobbler will generate a new
/etc/dhcp/dhcpd.conf
file and reload the dhcpd
service.
Cobbler manages DHCP by giving you automation where useful, while giving
you full control of what it does. It does so by using configuration file
templates. When running cobbler sync
these templates are used to
generate a configuration file and then reload the services.
The cobbler template for dhcpd
is /etc/cobbler/dhcp.template
.
Look at its contents, run cobbler sync
and verify how that template is rendered by looking at the
generated /etc/dhcp/dhcpd.conf
. It should look something like this:
Note
The cobbler sync
command will fail with an error, since the default
configuration seen below is not valid for us. This is normal.
# ******************************************************************
# Cobbler managed dhcpd.conf file
#
# generated from cobbler dhcp.conf template ($date)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
#
# ******************************************************************
#import netaddr
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = option vendor-class-identifier;
option system-arch code 93 = unsigned integer 16;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.5;
option domain-name-servers 192.168.1.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.100 192.168.1.254;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
# Legacy
if option system-arch = 00:00 {
filename "grub/grub.0";
}
# UEFI-32-1
if option system-arch = 00:06 {
# Not supported, no 32 bit UEFI grub executable
filename "unsupported";
}
# UEFI-32-2
if option system-arch = 00:02 {
# Not supported, no 32 bit UEFI grub executable
filename "unsupported";
}
# UEFI-64-1
else if option system-arch = 00:07 {
filename "grub/grubx64.efi";
}
# UEFI-64-2
else if option system-arch = 00:08 {
filename "grub/grubx64.efi";
}
# UEFI-64-3
else if option system-arch = 00:09 {
filename "grub/grubx64.efi";
}
# armv7 (aka arm 32 bit)
else if option system-arch = 00:0a {
filename "grub/armv7.efi";
}
# aarch64 (aka arm 64 bit)
else if option system-arch = 00:0b {
filename "grub/grubaa64.efi";
}
# RiskV 32 bit
else if option system-arch = 00:25 {
#ToDo petitboot loader
filename "unsupported";
}
#RiskV 32 bit
else if option system-arch = 00:27 {
#ToDo petitboot loader
filename "unsupported";
}
else if option system-arch = 00:0e {
filename "grub/grub.ppc64le";
}
else
{
filename "grub/grub.0";
}
}
}
#for dhcp_tag in $dhcp_tags.keys():
## group could be subnet if your dhcp tags line up with your subnets
## or really any valid dhcpd.conf construct ... if you only use the
## default dhcp tag in cobbler, the group block can be deleted for a
## flat configuration
# group for Cobbler DHCP tag: $dhcp_tag
group {
#for mac in $dhcp_tags[$dhcp_tag].keys():
#set iface = $dhcp_tags[$dhcp_tag][$mac]
#set mac_dhcp_format = netaddr.EUI($mac,dialect=netaddr.mac_unix)
host $iface.name {
#if $iface.interface_type == "infiniband":
option dhcp-client-identifier = $mac;
#else
hardware ethernet $mac_dhcp_format;
#end if
#if $iface.ip_address:
fixed-address $iface.ip_address;
#end if
#if $iface.dns_name:
option host-name "$iface.dns_name";
#else if $iface.hostname:
option host-name "$iface.hostname";
#end if
#if $iface.netmask:
option subnet-mask $iface.netmask;
#end if
#if $iface.if_gateway:
option routers $iface.if_gateway;
#else if $iface.gateway:
option routers $iface.gateway;
#end if
#if "filename" in $iface.keys() and $iface.filename:
#if $iface.enable_gpxe:
if exists user-class and option user-class = "gPXE" {
filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";
} else if exists user-class and option user-class = "iPXE" {
filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";
} else {
filename "undionly.kpxe";
}
#else
filename "$iface.filename";
#end if
#end if
#if $iface.next_server:
next-server $iface.next_server;
#end if
#if $iface.filename:
filename "$iface.filename";
#end if
#if $iface.name_servers:
#set $mynameservers = ','.join($iface.name_servers)
option domain-name-servers $mynameservers;
#end if
}
#end for
}
#end for
Modify the template in /etc/cobbler/dhcp.template
to include
both our management and cluster subnets. Remove the pxeclients
part and replace it with filename "pxelinux.0";
.
Warning
Make sure to remove range dynamic-bootp 192.168.1.100 192.168.1.254
from
the template and adjust all other subnet parameters to match the ones we had in
Exercise 2.
Leave other parts of the configuration file alone. Do not add
host
sections. These will be added automatically later.
Run cobbler sync
to update your DHCP configuration.
Your final generated DHCP configuration should have the following structure:
# ******************************************************************
# Cobbler managed dhcpd.conf file
#
# generated from cobbler dhcp.conf template ($date)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
#
# ******************************************************************
#import netaddr
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = option vendor-class-identifier;
option system-arch code 93 = unsigned integer 16;
subnet 192.168.0.0 netmask 255.255.240.0 {
...
}
subnet 192.168.16.0 netmask 255.255.240.0 {
...
next-server $next_server;
filename "pxelinux.0";
}
#for dhcp_tag in $dhcp_tags.keys():
...
#end for