ArticlesWarewulf

How to Add a Static DHCP Entry into Warewulf 4.5.x and 4.6.x

hostsstatictemplatewarewulfdhcp

Stephen Simpson
Senior Customer Support Engineer

Feb 14, 2025

Introduction

This article will cover assigning an IP address via DHCP using Warewulf, to a device that is not managed directly by Warewulf itself. This is useful in instances where you want to assign an address to a Network Attached Storage (NAS) device or similar non-compute node.

The implementation can be done by modifying the included DHCP template that comes with Warewulf.

Resolution

First, backup the DHCP template (this is optional but recommended):

# For Warewulf 4.5.x
cp /var/lib/warewulf/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww /var/lib/warewulf/overlays/host/rootfs/etc/dhcp/dhcpd.conf.bak

# For Warewulf 4.6.x
cp /usr/share/warewulf/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww /usr/share/warewulf/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww.bak

There are two implementation methods available: adding the entries directly or creating a separate entry under /etc/dhcp/hosts.conf and including each host there. Both of these will be explained below.

Option 1 - Add entries directly

You'll add each individual entry directly to the dhcpd.conf file. You will use the following entry as an example:

host MyDevice {
    hardware ethernet 00:11:22:33:44:55;
    fixed-address 10.0.0.5;
}

Edit the following template file /var/lib/warewulf/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww for Warewulf 4.5.x using vi or the text editor of your choice.

Alternatively for Warewulf 4.6.x, edit this template file instead: /usr/share/warewulf/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww

At the bottom of the dhcpd.conf.ww file, we are looking for the line {{/* dhcp enabled */}}.

Move this under the {{- end}} line.

In between the {{/* dhcp enabled */}} and {{- end}} lines, add your host entry, similar to the example below:

...
{{end -}}{{/* range NetDevs */}}
{{end -}}{{/* range AllNodes */}}
{{end -}}{{/* if static */}}
{{- else}}
{{abort}}
{{- end}}

host MyDevice {
    hardware ethernet 00:11:22:33:44:55;
    fixed-address 10.0.0.5;
}

{{/* dhcp enabled */}}

Add as many hosts as required.

Run the wwctl configure dhcp command to update the DHCP config.

Verify your hosts were added correctly using cat /etc/dhcpd.conf.

Option 2 - Include a separate hosts file

Instead of adding each host to the template individually, you can also create a separate file and then include this in the main template.

Create a hosts.conf file under /etc/dhcp/.

Edit the hosts.conf file and add each individual host. Please see example host additions below:

host MyDevice {
    hardware ethernet 00:11:22:33:44:55;
    fixed-address 10.0.0.5;
}

host MyOtherDevice {
    hardware ethernet AA:BB:CC:DD:EE:FF;
    fixed-address 10.0.0.6;
}

Now edit the template.

Similar to "Option 1 - add entries directly", we are looking for the {{/* dhcp enabled */}} line in the file.

Move the {{/* dhcp enabled */}} line under the {{- end}} line.

In the middle of the {{/* dhcp enabled */}} and {{- end}} lines, add your host information.

Edit the dhcpd.conf.ww template file.

For Warewulf 4.5.x, this file is located under /var/lib/warewulf/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww.

For Warewulf 4.6.x, this file is found under /usr/share/warewulf/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww. Exactly as before, you want to find the {{/* dhcp enabled */}} line.

Move this under the {{- end}} line.

Add your newly created hosts.conf via the Include line between the {{- end}} and {{/* dhcp enabled */}} lines. Below is an example:

...
{{end -}}{{/* range NetDevs */}}
{{end -}}{{/* range AllNodes */}}
{{end -}}{{/* if static */}}
{{- else}}
{{abort}}
{{- end}}

{{ Include "/etc/dhcp/hosts.conf" }}

{{/* dhcp enabled */}}

Again, run the wwctl configure dhcp command to update the DHCP config.

You can verify your hosts were added by checking the output of the cat /etc/dhcpd.conf command.

Conclusion

You have successfully assigned an IP address to a device via DHCP using Warewulf, therefore opening a world of possibilities to assign IPs to any device on your network; not just compute nodes. This shows just how flexible Warewulf is as a DHCP server, as well as for cluster management.

References & related articles

VI Text Editor: Link
Warewulf Configuration: Link