{"record":{"id":"5fe5bb17cffd7a10","repo":"AdguardTeam/AdGuardHome","slug":"bad-dhcpv6-configuration-w","errorCode":null,"errorMessage":"bad dhcpv6 configuration: %w","messagePattern":"bad dhcpv6 configuration: %w","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/dhcpd/http_unix.go","lineNumber":306,"sourceCode":"\tv6Conf.Logger = s.conf.Logger.With(\"ip_version\", \"6\")\n\tv6Conf.notify = s.onNotify\n\n\tsrv6, err = v6Create(v6Conf)\n\n\treturn srv6, enabled, err\n}\n\n// createServers returns DHCPv4 and DHCPv6 servers created from the provided\n// configuration conf.\nfunc (s *server) createServers(conf *dhcpServerConfigJSON) (srv4, srv6 DHCPServer, err error) {\n\tsrv4, v4Enabled, err := s.handleDHCPSetConfigV4(conf)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"bad dhcpv4 configuration: %w\", err)\n\t}\n\n\tsrv6, v6Enabled, err := s.handleDHCPSetConfigV6(conf)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"bad dhcpv6 configuration: %w\", err)\n\t}\n\n\tif conf.Enabled == aghalg.NBTrue && !v4Enabled && !v6Enabled {\n\t\treturn nil, nil, fmt.Errorf(\"dhcpv4 or dhcpv6 configuration must be complete\")\n\t}\n\n\treturn srv4, srv6, nil\n}\n\n// handleDHCPSetConfig is the handler for the POST /control/dhcp/set_config\n// HTTP API.\nfunc (s *server) handleDHCPSetConfig(w http.ResponseWriter, r *http.Request) {\n\tctx := r.Context()\n\tl := s.conf.Logger\n\n\tconf := &dhcpServerConfigJSON{}\n\tconf.Enabled = aghalg.BoolToNullBool(s.conf.Enabled)\n\tconf.InterfaceName = s.conf.InterfaceName","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/dhcpd/http_unix.go#L288-L324","documentation":"Raised inside createServers when the DHCPv6 portion of the submitted configuration fails validation in handleDHCPSetConfigV6. This covers bad IPv6 addresses in the range, invalid RA settings, or malformed string representations of IPv6 prefixes. The wrapped error identifies the exact field.","triggerScenarios":"POSTing dhcp/set_config with an invalid v6 block: range_start/range_end that are not a valid IPv6 pair, an invalid prefix length, or unparseable IPv6 literals (e.g. missing hex digits, wrong '::' usage).","commonSituations":"Confusing IPv4 and IPv6 fields in the config; using a /64 range whose start/end are reversed; mixing compressed and full IPv6 notation incorrectly; enabling DHCPv6 on a host without IPv6 support while also submitting malformed v6 data.","solutions":["Verify range_start and range_end are valid IPv6 literals and start < end (use net.ParseIP to test)","Ensure only the low 64 bits vary if using a /64 prefix, matching the server's expectations","Fix any typos in the v6 gateway/router advertisement fields and re-submit the config","If you do not need DHCPv6, disable the v6 block rather than leaving half-valid data"],"exampleFix":"// before\n{\"v6\":{\"range_start\":\"fd00::1\",\"range_end\":\"fd00::0\",...}}\n// -> 400 bad dhcpv6 configuration: ...\n\n// after\n{\"v6\":{\"range_start\":\"fd00::1\",\"range_end\":\"fd00::ff\",...}}","handlingStrategy":"validation","validationCode":"func validV6Range(start, end string) bool {\n\ts := net.ParseIP(start); e := net.ParseIP(end)\n\tif s == nil || e == nil || s.To4() != nil || e.To4() != nil { return false }\n\treturn bytes.Compare(s.To16(), e.To16()) < 0\n}","typeGuard":null,"tryCatchPattern":"if err := setDHCPConfig(cfg); err != nil {\n    if strings.HasPrefix(err.Error(), \"bad dhcpv6 configuration\") { /* inspect cfg.V6 fields */ }\n}","preventionTips":["Test IPv6 literals with net.ParseIP before submitting","If DHCPv6 is not needed, disable the v6 block rather than sending partial data","Ensure both addresses use the same prefix"],"tags":["dhcp","dhcpv6","validation","configuration","ipv6"],"backgroundTag":"invalid-ipv6-address","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}