{"record":{"id":"f7abe5fe87ea12f9","repo":"AdguardTeam/AdGuardHome","slug":"setting-static-ip-w","errorCode":null,"errorMessage":"setting static ip: %w","messagePattern":"setting static ip: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"internal/dhcpd/http_unix.go","lineNumber":212,"sourceCode":"\t\t\tlog.Info(\"error while checking static ip: %s; \"+\n\t\t\t\t\"assuming machine has static ip and going on\", err)\n\t\t\thasStaticIP = true\n\t\t} else if errors.Is(err, aghnet.ErrNoStaticIPInfo) {\n\t\t\t// Couldn't obtain a definitive answer.  Assume static IP an go on.\n\t\t\tlog.Info(\"can't check for static ip; \" +\n\t\t\t\t\"assuming machine has static ip and going on\")\n\t\t\thasStaticIP = true\n\t\t} else {\n\t\t\terr = fmt.Errorf(\"checking static ip: %w\", err)\n\n\t\t\treturn http.StatusInternalServerError, err\n\t\t}\n\t}\n\n\tif !hasStaticIP {\n\t\terr = aghnet.IfaceSetStaticIP(ctx, s.conf.Logger, cmdCons, ifaceName)\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"setting static ip: %w\", err)\n\n\t\t\treturn http.StatusInternalServerError, err\n\t\t}\n\t}\n\n\terr = s.Start(ctx)\n\tif err != nil {\n\t\treturn http.StatusBadRequest, fmt.Errorf(\"starting dhcp server: %w\", err)\n\t}\n\n\treturn 0, nil\n}\n\ntype dhcpServerConfigJSON struct {\n\tV4            *v4ServerConfJSON `json:\"v4\"`\n\tV6            *v6ServerConfJSON `json:\"v6\"`\n\tInterfaceName string            `json:\"interface_name\"`\n\tEnabled       aghalg.NullBool   `json:\"enabled\"`","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/dhcpd/http_unix.go#L194-L230","documentation":"While enabling DHCP on an interface that does not currently have a static IP, AdGuard Home attempted to set a static IP via IfaceSetStaticIP and it failed; returned as HTTP 500 wrapped as 'setting static ip'.","triggerScenarios":"Calling handleDHCPSetConfig to enable DHCP when hasStaticIP is false and the command-based static IP configuration (network manager / ip commands) errors — insufficient privileges, unsupported network manager, or missing tooling.","commonSituations":"Running the binary without root/CAP_NET_ADMIN; distros with unsupported network managers; containers where host network modification is blocked.","solutions":["Run the service with sufficient privileges (root or CAP_NET_ADMIN)","Set a static IP on the interface manually beforehand, so the code skips this step","Use an environment where the supported network configuration tools exist"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// set static IP yourself beforehand so IfaceSetStaticIP is skipped\n// e.g. configure via netplan/NM, then verify:\n// ip -4 addr show <iface> | grep -q 'dynamic' || echo static","typeGuard":null,"tryCatchPattern":"if err := enableDHCP(...); err != nil && strings.Contains(err.Error(), \"setting static ip\") { /* retry with elevated privileges or pre-configure statically */ }","preventionTips":["Pre-configure a static IP on the DHCP interface","Run the service as root or with CAP_NET_ADMIN","Use supported network managers on the host"],"tags":["dhcp","network","static-ip","permissions","http-500"],"backgroundTag":"static-ip-set-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}