{"record":{"id":"e9dd3da9b58dd6dc","repo":"AdguardTeam/AdGuardHome","slug":"bad-dhcpv4-configuration-w","errorCode":null,"errorMessage":"bad dhcpv4 configuration: %w","messagePattern":"bad dhcpv4 configuration: %w","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/dhcpd/http_unix.go","lineNumber":301,"sourceCode":"\tv6Conf.RASLAACOnly = s.conf.Conf6.RASLAACOnly\n\tv6Conf.RAAllowSLAAC = s.conf.Conf6.RAAllowSLAAC\n\n\tenabled = v6Conf.Enabled\n\tv6Conf.InterfaceName = conf.InterfaceName\n\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()","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/dhcpd/http_unix.go#L283-L319","documentation":"Raised inside createServers when the DHCPv4 portion of the submitted configuration is invalid. handleDHCPSetConfigV4 validates fields such as the IPv4 range (start/end), gateway, subnet mask, and lease duration; any failure is wrapped as 'bad dhcpv4 configuration'. The HTTP request is rejected before any server is started.","triggerScenarios":"POSTing dhcp/set_config with an invalid IPv4 block: range_start >= range_end, range outside the subnet, a malformed gateway/subnet_mask IP, or a range that exceeds the maximum allowed size.","commonSituations":"Typos in range_start/range_end (transposed octets), using /8-sized subnets that blow the max range length, entering a DNS server or gateway that is not a valid IPv4 address, or copying a config between machines with different subnets.","solutions":["Check range_start is strictly less than range_end and both are valid IPv4 addresses","Ensure the range lies within the configured subnet and is not larger than the max range length","Validate gateway, subnet_mask, and all IP fields parse as dotted-quad IPv4","Correct the JSON payload and re-POST; use GET /control/dhcp/status first to inspect current values"],"exampleFix":"// before\n{\"enabled\":true,\"v4\":{\"range_start\":\"192.168.1.100\",\"range_end\":\"192.168.1.50\",...}}\n// -> 400 bad dhcpv4 configuration: start is greater than or equal to end\n\n// after\n{\"enabled\":true,\"v4\":{\"range_start\":\"192.168.1.50\",\"range_end\":\"192.168.1.100\",...}}","handlingStrategy":"validation","validationCode":"func validV4Range(start, end string) bool {\n\ts := net.ParseIP(start).To4(); e := net.ParseIP(end).To4()\n\treturn s != nil && e != nil && binary.BigEndian.Uint32(s) < binary.BigEndian.Uint32(e)\n}","typeGuard":null,"tryCatchPattern":"if err := setDHCPConfig(cfg); err != nil {\n    if strings.HasPrefix(err.Error(), \"bad dhcpv4 configuration\") { /* inspect cfg.V4 fields */ }\n}","preventionTips":["Validate range/gateway/subnet fields client-side before POST","Never submit range_start >= range_end","Keep the range inside the configured subnet"],"tags":["dhcp","dhcpv4","validation","configuration","adguard-home"],"backgroundTag":"invalid-ip-range","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}