{"record":{"id":"4323da35fef5cf5a","repo":"AdguardTeam/AdGuardHome","slug":"creating-dhcpv4-srv-w","errorCode":null,"errorMessage":"creating dhcpv4 srv: %w","messagePattern":"creating dhcpv4 srv: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/dhcpd/dhcpd.go","lineNumber":176,"sourceCode":"}\n\n// setServers updates DHCPv4 and DHCPv6 servers created from the provided\n// configuration conf.  It returns the status of both the DHCPv4 and the DHCPv6\n// servers, which is always false for corresponding server on any error.\nfunc (s *server) setServers(\n\tctx context.Context,\n\tconf *ServerConfig,\n) (v4Enabled, v6Enabled bool, err error) {\n\tv4conf := conf.Conf4\n\tv4conf.Logger = s.conf.Logger.With(\"ip_version\", \"4\")\n\tv4conf.InterfaceName = s.conf.InterfaceName\n\tv4conf.notify = s.onNotify\n\tv4conf.Enabled = s.conf.Enabled && v4conf.RangeStart.IsValid()\n\n\ts.srv4, err = v4Create(&v4conf)\n\tif err != nil {\n\t\tif v4conf.Enabled {\n\t\t\treturn false, false, fmt.Errorf(\"creating dhcpv4 srv: %w\", err)\n\t\t}\n\n\t\ts.conf.Logger.DebugContext(ctx, \"creating dhcpv4 server\", slogutil.KeyError, err)\n\t}\n\n\tv6conf := conf.Conf6\n\tv6conf.Logger = s.conf.Logger.With(\"ip_version\", \"6\")\n\tv6conf.InterfaceName = s.conf.InterfaceName\n\tv6conf.notify = s.onNotify\n\tv6conf.Enabled = s.conf.Enabled && len(v6conf.RangeStart) != 0\n\n\ts.srv6, err = v6Create(v6conf)\n\tif err != nil {\n\t\treturn v4conf.Enabled, false, fmt.Errorf(\"creating dhcpv6 srv: %w\", err)\n\t}\n\n\treturn v4conf.Enabled, v6conf.Enabled, nil\n}","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/dhcpd/dhcpd.go#L158-L194","documentation":"Creating the DHCPv4 server (v4Create) failed and the v4 config was considered enabled (valid RangeStart), so setServers propagates the error and Create aborts. Typical wrapped causes are invalid ranges, gateway, or interface binding failures inside v4Create/Validate.","triggerScenarios":"Calling Create with DHCPv4 enabled and RangeStart set but another setting invalid (range end outside subnet, gateway inside range, bad interface) — the Validate errors 103–106 surface through this wrapper.","commonSituations":"Applying a new DHCP config via the UI/API with an inconsistent range/gateway/subnet combination; interface renamed or missing.","solutions":["Inspect the wrapped error for the concrete validation failure (range/gateway/subnet)","Correct the DHCPv4 settings per the underlying message","Verify the network interface name exists and is up"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// run config validation before Create\nif err := conf.Conf4.Validate(); err != nil { return err } // surfaces range/gateway issues early","typeGuard":null,"tryCatchPattern":"if _, err := dhcpd.Create(ctx, conf); err != nil && strings.Contains(err.Error(), \"creating dhcpv4\") { /* show wrapped validation detail to user */ }","preventionTips":["Pre-validate ranges, gateway, subnet consistency in UI","Confirm interface name exists before applying"],"tags":["dhcp","ipv4","startup","validation"],"backgroundTag":"dhcp-server-create-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}