diff --git a/overlays/host/etc/dhcp/dhcpd.conf.ww b/overlays/host/etc/dhcp/dhcpd.conf.ww index 46922ae9..c93e318c 100644 --- a/overlays/host/etc/dhcp/dhcpd.conf.ww +++ b/overlays/host/etc/dhcp/dhcpd.conf.ww @@ -1,4 +1,4 @@ -{{- if .Dhcp.Enabled }} +{{if .Dhcp.Enabled -}} # This file is autogenerated by warewulf # Host: {{.BuildHost}} # Time: {{.BuildTime}} @@ -35,12 +35,29 @@ if exists user-class and option user-class = "iPXE" { } } +{{if eq .Dhcp.Template "static" -}} +subnet {{$.Network}} netmask {{$.Netmask}} { + next-server {{$.Ipaddr}}; +} +{{range $nodes := .AllNodes}} +{{- range $netdevs := $nodes.NetDevs}} +{{- if $netdevs.Default.Get}} +host {{$nodes.Id.Get}} { + hardware ethernet {{$netdevs.Hwaddr.Get}}; + fixed-address {{$netdevs.Ipaddr.Get}}; +} +{{end -}} +{{end -}} +{{end -}} + +{{else -}} subnet {{$.Network}} netmask {{$.Netmask}} { max-lease-time 120; range {{$.Dhcp.RangeStart}} {{$.Dhcp.RangeEnd}}; next-server {{$.Ipaddr}}; } -{{- else }} -{{ abort }} -{{- end }} +{{end}} +{{- else}} +{{abort}} +{{- end}}