{"record":{"id":"06bf15c5b6f7f999","repo":"TechnitiumSoftware/DnsServer","slug":"dhcp-server-requires-static-ip-address-to-work-cor","errorCode":null,"errorMessage":"DHCP Server requires static IP address to work correctly but no network interface was found to have any static IP address configured.","messagePattern":"DHCP Server requires static IP address to work correctly but no network interface was found to have any static IP address configured\\.","errorType":"exception","errorClass":"DhcpServerException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dhcp/DhcpServer.cs","lineNumber":1102,"sourceCode":"            try\n            {\n                //find scope interface for binding socket\n                if (waitForInterface)\n                {\n                    //retry for 30 seconds for interface to come up\n                    int tries = 0;\n                    while (true)\n                    {\n                        if (scope.FindInterface())\n                        {\n                            if (!scope.InterfaceAddress.Equals(IPAddress.Any))\n                                break; //break only when specific interface address is found\n                        }\n\n                        if (++tries >= 30)\n                        {\n                            if (scope.InterfaceAddress == null)\n                                throw new DhcpServerException(\"DHCP Server requires static IP address to work correctly but no network interface was found to have any static IP address configured.\");\n\n                            break; //use the available ANY interface address\n                        }\n\n                        await Task.Delay(1000);\n                    }\n                }\n                else\n                {\n                    if (!scope.FindInterface())\n                        throw new DhcpServerException(\"DHCP Server requires static IP address to work correctly but no network interface was found to have any static IP address configured.\");\n                }\n\n                //find this dns server address in case the network config has changed\n                if (scope.UseThisDnsServer)\n                    scope.FindThisDnsServerAddress();\n\n                dhcpEP = new IPEndPoint(scope.InterfaceAddress, 67);","sourceCodeStart":1084,"sourceCodeEnd":1120,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dhcp/DhcpServer.cs#L1084-L1120","documentation":"Thrown from the waitForInterface retry loop in DhcpServer scope activation. The server retried finding a network interface for ~30 seconds (30 x 1s) and scope.InterfaceAddress was still null, meaning no interface with a matching static IP for this scope's range was found.","triggerScenarios":"LoadScopeAsync/ActivateScopeAsync with waitForInterface=true. After `++tries >= 30` the loop exits and `scope.InterfaceAddress == null`, so no usable IPv4 interface exists for the scope's network.","commonSituations":"Host has no static IPv4 address on the scope subnet (DHCP-assigned or unconfigured NIC). Interface came up too slowly (>30s). Subnet mask / gateway mismatch so FindInterface never matches. Container/VM without a bridged interface.","solutions":["Assign a static IPv4 address on the correct subnet to a host interface, then restart the DHCP server.","Verify the scope's starting/ending address and subnet mask match an attached interface's network.","Increase readiness of the interface (start the service after networking is up) or pass waitForInterface=false during manual scope load.","If running in a container, attach a host network/bridge with a static IP."],"exampleFix":"// before: interface is DHCP-assigned, scope waits 30s then throws\n// after: set static IP on eth0 in the scope subnet\n//   ip addr add 192.168.1.10/24 dev eth0\n// then start the service","handlingStrategy":"retry","validationCode":"if (!scope.FindInterface() || scope.InterfaceAddress == null)\n    throw new InvalidOperationException(\"No static IPv4 interface on subnet \" + scope.StartingAddress + \"/\" + scope.SubnetMask);","typeGuard":"static bool ScopeHasInterface(Scope s) => s.FindInterface() && s.InterfaceAddress != null && !s.InterfaceAddress.Equals(IPAddress.Any);","tryCatchPattern":"try { await _dhcpServer.ActivateScopeAsync(scope, waitForInterface: true); }\ncatch (DhcpServerException ex) when (ex.Message.Contains(\"no network interface was found\"))\n{ /* configure static IP, then re-add scope */ }","preventionTips":["Configure a static IPv4 on the host before enabling scopes.","Start the DHCP service after the network target is online.","Validate FindInterface in the UI before persisting a scope."],"tags":["dhcp","networking","ipv4","startup","static-ip"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}