Add IpCIDR6 and IPv6 DHCP range

Signed-off-by: Timothy Middelkoop <tmiddelkoop@internet2.edu>
This commit is contained in:
Timothy Middelkoop
2025-11-17 17:53:09 +00:00
parent 5314a4c858
commit 463994976e
7 changed files with 24 additions and 2 deletions

View File

@@ -11,6 +11,8 @@ type DHCPConf struct {
Template string `yaml:"template,omitempty" default:"default"`
RangeStart string `yaml:"range start,omitempty"`
RangeEnd string `yaml:"range end,omitempty"`
Range6Start string `yaml:"range6 start,omitempty"`
Range6End string `yaml:"range6 end,omitempty"`
SystemdName string `yaml:"systemd name,omitempty" default:"dhcpd"`
}

View File

@@ -29,6 +29,7 @@ type WarewulfYaml struct {
Ipaddr6 string `yaml:"ipaddr6,omitempty"`
Netmask string `yaml:"netmask,omitempty"`
Network string `yaml:"network,omitempty"`
IpCIDR6 string `yaml:"-"`
Fqdn string `yaml:"fqdn,omitempty"`
Warewulf *WarewulfConf `yaml:"warewulf,omitempty"`
API *APIConf `yaml:"api,omitempty"`
@@ -140,7 +141,13 @@ func (conf *WarewulfYaml) Parse(data []byte, autodetect bool) error {
}
if conf.Ipaddr6 != "" {
if _, _, err := net.ParseCIDR(conf.Ipaddr6); err != nil {
if ip, _, err := net.ParseCIDR(conf.Ipaddr6); err == nil {
if ip.To4() != nil {
return fmt.Errorf("invalid ipv6 address: ip address is ipv4: %s", conf.Ipaddr6)
}
conf.IpCIDR6 = conf.Ipaddr6
conf.Ipaddr6 = ip.String()
} else {
return fmt.Errorf("invalid ipv6 address: must use CIDR notation: %s", conf.Ipaddr6)
}
}

View File

@@ -152,7 +152,7 @@ api:
ipaddr6: "2001:db8::1/64"
`,
result: `
ipaddr6: "2001:db8::1/64"
ipaddr6: "2001:db8::1"
warewulf:
autobuild overlays: true
grubboot: false