Merge dnsmasq ipv4 and ipv6 files

Signed-off-by: Timothy Middelkoop <tmiddelkoop@internet2.edu>
This commit is contained in:
Timothy Middelkoop
2025-11-29 02:12:19 +00:00
parent 4c82de92c7
commit 223f56a330
6 changed files with 60 additions and 75 deletions

View File

@@ -20,7 +20,6 @@ func Test_hostOverlay(t *testing.T) {
env.ImportFile("etc/warewulf/nodes.conf", "nodes.conf") env.ImportFile("etc/warewulf/nodes.conf", "nodes.conf")
env.ImportFile("var/lib/warewulf/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww", "../rootfs/etc/dhcp/dhcpd.conf.ww") env.ImportFile("var/lib/warewulf/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww", "../rootfs/etc/dhcp/dhcpd.conf.ww")
env.ImportFile("var/lib/warewulf/overlays/host/rootfs/etc/dnsmasq.d/ww4-hosts.conf.ww", "../rootfs/etc/dnsmasq.d/ww4-hosts.conf.ww") env.ImportFile("var/lib/warewulf/overlays/host/rootfs/etc/dnsmasq.d/ww4-hosts.conf.ww", "../rootfs/etc/dnsmasq.d/ww4-hosts.conf.ww")
env.ImportFile("var/lib/warewulf/overlays/host/rootfs/etc/dnsmasq.d/ww4-hosts6.conf.ww", "../rootfs/etc/dnsmasq.d/ww4-hosts6.conf.ww")
env.ImportFile("var/lib/warewulf/overlays/host/rootfs/etc/exports.ww", "../rootfs/etc/exports.ww") env.ImportFile("var/lib/warewulf/overlays/host/rootfs/etc/exports.ww", "../rootfs/etc/exports.ww")
env.ImportFile("var/lib/warewulf/overlays/host/rootfs/etc/hosts.ww", "../rootfs/etc/hosts.ww") env.ImportFile("var/lib/warewulf/overlays/host/rootfs/etc/hosts.ww", "../rootfs/etc/hosts.ww")
env.ImportFile("var/lib/warewulf/overlays/host/rootfs/etc/profile.d/ssh_setup.csh.ww", "../rootfs/etc/profile.d/ssh_setup.csh.ww") env.ImportFile("var/lib/warewulf/overlays/host/rootfs/etc/profile.d/ssh_setup.csh.ww", "../rootfs/etc/profile.d/ssh_setup.csh.ww")
@@ -54,13 +53,6 @@ func Test_hostOverlay(t *testing.T) {
log: host_dnsmasq, log: host_dnsmasq,
header: "", header: "",
}, },
{
name: "host:dnsmasq6",
conf: "warewulf.conf-ipv6",
args: []string{"--render", "host", "host", "etc/dnsmasq.d/ww4-hosts6.conf.ww"},
log: host_dnsmasq6,
header: "",
},
{ {
name: "host:/etc/exports", name: "host:/etc/exports",
conf: "", conf: "",
@@ -274,40 +266,26 @@ dhcp-boot=tag:iPXE,"http://192.168.0.1:9873/ipxe/${mac:hexhyp}?assetkey=${asset}
dhcp-no-override dhcp-no-override
# define the the range # define the the range
dhcp-range=192.168.0.100,192.168.0.199,255.255.255.0,6h dhcp-range=192.168.0.100,192.168.0.199,255.255.255.0,6h
dhcp-host=e6:92:39:49:7b:03,set:warewulf,node1,192.168.3.21,infinite
dhcp-host=9a:77:29:73:14:f1,set:warewulf,node1,192.168.3.22,infinite
dhcp-host=e6:92:39:49:7b:04,set:warewulf,node2,192.168.3.23,infinite
`
const host_dnsmasq6 string = `backupFile: false # IPv6 routing announcements
writeFile: true
Filename: etc/dnsmasq.d/ww4-hosts6.conf
# This file was autgenerated by warewulf
# enable services
enable-ra enable-ra
enable-tftp
# match archtecture (client-arch=61) # IPv6 matching (client-arch=61)
dhcp-match=set:x86PC,option6:61,0007 # EFI x86-64 dhcp-match=set:x86PC,option6:61,0007 # EFI x86-64
dhcp-match=set:aarch64,option6:61,0011 # EFI aarch64 dhcp-match=set:aarch64,option6:61,0011 # EFI aarch64
dhcp-vendorclass=set:x86PC,enterprise:343,PXEClient:Arch:00007 # EFI x86-64 dhcp-vendorclass=set:x86PC,enterprise:343,PXEClient:Arch:00007 # EFI x86-64
dhcp-vendorclass=set:aarch64,enterprise:343,PXEClient:Arch:00011 # EFI aarch64 dhcp-vendorclass=set:aarch64,enterprise:343,PXEClient:Arch:00011 # EFI aarch64
# match iPXE # IPv6 bootfile-url (iPXE EFI binary)
dhcp-userclass=set:iPXE,iPXE
# send iPXE EFI binary
dhcp-option=tag:x86PC,option6:bootfile-url,"tftp://[2001:db8::1]/warewulf/ipxe-snponly-x86_64.efi" dhcp-option=tag:x86PC,option6:bootfile-url,"tftp://[2001:db8::1]/warewulf/ipxe-snponly-x86_64.efi"
dhcp-option=tag:aarch64,option6:bootfile-url,"tftp://[2001:db8::1]/warewulf/snponly.efi" dhcp-option=tag:aarch64,option6:bootfile-url,"tftp://[2001:db8::1]/warewulf/snponly.efi"
# iPXE binary will get the following configuration file # IPv6 iPXE binary will get the following configuration file
dhcp-option=tag:iPXE,option6:bootfile-url,"http://[2001:db8::1]:9873/ipxe/${mac:hexhyp}?assetkey=${asset}&uuid=${uuid}" dhcp-option=tag:iPXE,option6:bootfile-url,"http://[2001:db8::1]:9873/ipxe/${mac:hexhyp}?assetkey=${asset}&uuid=${uuid}"
# DHCP range and entries # hosts
dhcp-range=2001:db8::100,2001:db8::0:1FF,6h dhcp-host=e6:92:39:49:7b:03,id:00:03:00:01:e6:92:39:49:7b:03,set:warewulf,192.168.3.21,[2001:db8::111],node1,infinite
dhcp-host=e6:92:39:49:7b:03,set:warewulf,node1,2001:db8::111,infinite dhcp-host=9a:77:29:73:14:f1,id:00:03:00:01:9a:77:29:73:14:f1,set:warewulf,192.168.3.22,[2001:db8::112],node1,infinite
dhcp-host=9a:77:29:73:14:f1,set:warewulf,node1,2001:db8::112,infinite dhcp-host=e6:92:39:49:7b:04,id:00:03:00:01:e6:92:39:49:7b:04,set:warewulf,192.168.3.23,[2001:db8::121],node2,infinite
dhcp-host=e6:92:39:49:7b:04,set:warewulf,node2,2001:db8::121,infinite
` `
const host_exports string = `backupFile: true const host_exports string = `backupFile: true

View File

@@ -1,4 +1,5 @@
ipaddr: 192.168.0.1/24 ipaddr: 192.168.0.1/24
ipaddr6: 2001:db8::1/64
netmask: 255.255.255.0 netmask: 255.255.255.0
network: 192.168.0.0 network: 192.168.0.0
warewulf: warewulf:

View File

@@ -34,10 +34,47 @@ tftp-root={{ $.Tftp.TftpRoot }}
# define the the range # define the the range
dhcp-range={{$.Dhcp.RangeStart}},{{$.Dhcp.RangeEnd}},{{$.Netmask}},6h dhcp-range={{$.Dhcp.RangeStart}},{{$.Dhcp.RangeEnd}},{{$.Netmask}},6h
{{ end -}} {{ end -}}
{{ if and $.Dhcp.Range6Start $.Dhcp.Range6End -}}
dhcp-range={{$.Dhcp.Range6Start}},{{$.Dhcp.Range6End}},6h
{{ end -}}
{{- if .Ipv6 }}
# IPv6 routing announcements
enable-ra
# IPv6 matching (client-arch=61)
dhcp-match=set:x86PC,option6:61,0007 # EFI x86-64
dhcp-match=set:aarch64,option6:61,0011 # EFI aarch64
dhcp-vendorclass=set:x86PC,enterprise:343,PXEClient:Arch:00007 # EFI x86-64
dhcp-vendorclass=set:aarch64,enterprise:343,PXEClient:Arch:00011 # EFI aarch64
# IPv6 bootfile-url (iPXE EFI binary)
{{ with (index $.Tftp.IpxeBinaries "00:07" ) -}}
dhcp-option=tag:x86PC,option6:bootfile-url,"tftp://[{{$.Ipaddr6}}]/warewulf/{{ index $.Tftp.IpxeBinaries "00:07" }}"
{{ end -}}
{{ with (index $.Tftp.IpxeBinaries "00:0B" ) -}}
dhcp-option=tag:aarch64,option6:bootfile-url,"tftp://[{{$.Ipaddr6}}]/warewulf/{{ index $.Tftp.IpxeBinaries "00:0B" | basename }}"
{{ end -}}
# IPv6 iPXE binary will get the following configuration file
dhcp-option=tag:iPXE,option6:bootfile-url,"http://[{{$.Ipaddr6}}]:{{$.Warewulf.Port}}/ipxe/${mac:hexhyp}?assetkey=${asset}&uuid=${uuid}"
{{- end }}
# hosts
{{ range $node := $.AllNodes -}} {{ range $node := $.AllNodes -}}
{{ range $devname, $netdev := $node.NetDevs -}} {{ range $devname, $netdev := $node.NetDevs -}}
{{ if and $netdev.Ipaddr $netdev.Hwaddr -}} dhcp-host=
dhcp-host={{$netdev.Hwaddr}},set:warewulf,{{$node.Id}},{{$netdev.Ipaddr}},infinite {{- if $netdev.Hwaddr -}}
{{- end }} {{$netdev.Hwaddr}},id:00:03:00:01:{{$netdev.Hwaddr}},
{{- end -}}
set:warewulf,
{{- if $netdev.Ipaddr -}}
{{- $netdev.Ipaddr -}},
{{- end -}}
{{- if $netdev.Ipaddr6 -}}
[{{$netdev.Ipaddr6}}],
{{- end -}}
{{$node.Id}},infinite
{{ end -}} {{ end -}}
{{ end -}} {{ end -}}

View File

@@ -1,39 +0,0 @@
# This file was autgenerated by warewulf
{{ nobackup }}
{{ if .Ipv6 -}}
# enable services
enable-ra
enable-tftp
# match archtecture (client-arch=61)
dhcp-match=set:x86PC,option6:61,0007 # EFI x86-64
dhcp-match=set:aarch64,option6:61,0011 # EFI aarch64
dhcp-vendorclass=set:x86PC,enterprise:343,PXEClient:Arch:00007 # EFI x86-64
dhcp-vendorclass=set:aarch64,enterprise:343,PXEClient:Arch:00011 # EFI aarch64
# match iPXE
dhcp-userclass=set:iPXE,iPXE
# send iPXE EFI binary
{{ with (index $.Tftp.IpxeBinaries "00:07" ) -}}
dhcp-option=tag:x86PC,option6:bootfile-url,"tftp://[{{$.Ipaddr6}}]/warewulf/{{ index $.Tftp.IpxeBinaries "00:07" }}"
{{ end -}}
{{ with (index $.Tftp.IpxeBinaries "00:0B" ) -}}
dhcp-option=tag:aarch64,option6:bootfile-url,"tftp://[{{$.Ipaddr6}}]/warewulf/{{ index $.Tftp.IpxeBinaries "00:0B" | basename }}"
{{ end -}}
# iPXE binary will get the following configuration file
dhcp-option=tag:iPXE,option6:bootfile-url,"http://[{{$.Ipaddr6}}]:{{$.Warewulf.Port}}/ipxe/${mac:hexhyp}?assetkey=${asset}&uuid=${uuid}"
# DHCP range and entries
{{ if and $.Dhcp.Range6Start $.Dhcp.Range6End -}}
dhcp-range={{$.Dhcp.Range6Start}},{{$.Dhcp.Range6End}},6h
{{ end -}}
{{ range $node := $.AllNodes -}}
{{ range $devname, $netdev := $node.NetDevs -}}
{{ if and $netdev.Ipaddr6 $netdev.Hwaddr -}}
dhcp-host={{$netdev.Hwaddr}},set:warewulf,{{$node.Id}},{{$netdev.Ipaddr6}},infinite
{{ end -}}
{{ end -}}
{{ end -}}
{{ end -}}

View File

@@ -69,6 +69,7 @@ MACAddress=e6:92:39:49:7b:03
DHCP=no DHCP=no
Address=192.168.3.21/24 Address=192.168.3.21/24
Gateway=192.168.3.1 Gateway=192.168.3.1
[Link] [Link]
MTUBytes=1500 MTUBytes=1500
backupFile: true backupFile: true
@@ -83,9 +84,11 @@ MACAddress=9a:77:29:73:14:f1
DHCP=no DHCP=no
Address=192.168.3.22/24 Address=192.168.3.22/24
Gateway=192.168.3.1 Gateway=192.168.3.1
IPv6AcceptRA=no
IPv6PrivacyExtensions=false IPv6PrivacyExtensions=false
Address=2001:db8::23/64 Address=2001:db8::23/64
Gateway=2001:db8::1 Gateway=2001:db8::1
[Link] [Link]
MTUBytes=9000 MTUBytes=9000
@@ -94,7 +97,7 @@ Destination=192.168.1.0/24
Gateway=192.168.3.254 Gateway=192.168.3.254
[DHCPv6] [DHCPv6]
UseAddress=no DUIDType=link-layer
` `
const expected_log_without_hwaddr string = `backupFile: true const expected_log_without_hwaddr string = `backupFile: true
@@ -109,6 +112,7 @@ Name=wwnet0
DHCP=no DHCP=no
Address=192.168.3.21/24 Address=192.168.3.21/24
Gateway=192.168.3.1 Gateway=192.168.3.1
[Link] [Link]
MTUBytes=1500 MTUBytes=1500
backupFile: true backupFile: true
@@ -122,9 +126,11 @@ Name=wwnet1
DHCP=no DHCP=no
Address=192.168.3.22/24 Address=192.168.3.22/24
Gateway=192.168.3.1 Gateway=192.168.3.1
IPv6AcceptRA=no
IPv6PrivacyExtensions=false IPv6PrivacyExtensions=false
Address=2001:db8::23/64 Address=2001:db8::23/64
Gateway=2001:db8::1 Gateway=2001:db8::1
[Link] [Link]
MTUBytes=9000 MTUBytes=9000
@@ -133,5 +139,5 @@ Destination=192.168.1.0/24
Gateway=192.168.3.254 Gateway=192.168.3.254
[DHCPv6] [DHCPv6]
UseAddress=no DUIDType=link-layer
` `

View File

@@ -20,6 +20,7 @@ Address={{ $netdev.IpCIDR }}
Gateway={{ $netdev.Gateway }} Gateway={{ $netdev.Gateway }}
{{- end }} {{- end }}
{{- if $netdev.IpCIDR6 }} {{- if $netdev.IpCIDR6 }}
IPv6AcceptRA=no
IPv6PrivacyExtensions=false IPv6PrivacyExtensions=false
Address={{ $netdev.IpCIDR6 }} Address={{ $netdev.IpCIDR6 }}
{{- end }} {{- end }}
@@ -33,6 +34,7 @@ DNS={{ $tv }}
{{- end }} {{- end }}
{{- if $netdev.MTU }} {{- if $netdev.MTU }}
[Link] [Link]
MTUBytes={{ $netdev.MTU }} MTUBytes={{ $netdev.MTU }}
{{- end }} {{- end }}
@@ -49,7 +51,7 @@ Gateway={{ index $route 1 }}
{{- if $netdev.Ipaddr6 }} {{- if $netdev.Ipaddr6 }}
[DHCPv6] [DHCPv6]
UseAddress=no DUIDType=link-layer
{{ end -}} {{ end -}}
{{ end -}} {{ end -}}