{"record":{"id":"4d46019f6a783b69","repo":"TechnitiumSoftware/DnsServer","slug":"cannot-update-reverse-dns-zone-reversezoneinfo-d","errorCode":null,"errorMessage":"Cannot update reverse DNS zone '{reverseZoneInfo.DisplayName}': not a primary or a forwarder zone.","messagePattern":"Cannot update reverse DNS zone '(.+?)': not a primary or a forwarder zone\\.","errorType":"exception","errorClass":"DhcpServerException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dhcp/DhcpServer.cs","lineNumber":896,"sourceCode":"                    {\n                        _log.Write(\"DHCP Server failed to create DNS primary zone '\" + reverseZone + \"'.\");\n                        return;\n                    }\n\n                    //set permissions\n                    _authManager.SetPermission(PermissionSection.Zones, reverseZoneInfo.Name, _authManager.GetGroup(Group.ADMINISTRATORS), PermissionFlag.ViewModifyDelete);\n                    _authManager.SetPermission(PermissionSection.Zones, reverseZoneInfo.Name, _authManager.GetGroup(Group.DNS_ADMINISTRATORS), PermissionFlag.ViewModifyDelete);\n                    _authManager.SetPermission(PermissionSection.Zones, reverseZoneInfo.Name, _authManager.GetGroup(Group.DHCP_ADMINISTRATORS), PermissionFlag.ViewModifyDelete);\n                    _authManager.SaveConfigFile();\n\n                    _log.Write(\"DHCP Server create DNS primary zone '\" + reverseZoneInfo.DisplayName + \"'.\");\n                }\n                else if ((reverseZoneInfo.Type != AuthZoneType.Primary) && (reverseZoneInfo.Type != AuthZoneType.Forwarder))\n                {\n                    string reverseZone = Zone.GetReverseZone(address, scope.SubnetMask);\n\n                    if (reverseZoneInfo.Name.Equals(reverseZone, StringComparison.OrdinalIgnoreCase))\n                        throw new DhcpServerException(\"Cannot update reverse DNS zone '\" + reverseZoneInfo.DisplayName + \"': not a primary or a forwarder zone.\");\n\n                    //create new reverse primary zone\n                    reverseZoneInfo = _dnsServer.AuthZoneManager.CreatePrimaryZone(reverseZone);\n                    if (reverseZoneInfo is null)\n                    {\n                        _log.Write(\"DHCP Server failed to create DNS primary zone '\" + reverseZone + \"'.\");\n                        return;\n                    }\n\n                    //set permissions\n                    _authManager.SetPermission(PermissionSection.Zones, reverseZoneInfo.Name, _authManager.GetGroup(Group.ADMINISTRATORS), PermissionFlag.ViewModifyDelete);\n                    _authManager.SetPermission(PermissionSection.Zones, reverseZoneInfo.Name, _authManager.GetGroup(Group.DNS_ADMINISTRATORS), PermissionFlag.ViewModifyDelete);\n                    _authManager.SetPermission(PermissionSection.Zones, reverseZoneInfo.Name, _authManager.GetGroup(Group.DHCP_ADMINISTRATORS), PermissionFlag.ViewModifyDelete);\n                    _authManager.SaveConfigFile();\n\n                    _log.Write(\"DHCP Server create DNS primary zone '\" + reverseZoneInfo.DisplayName + \"'.\");\n                }\n","sourceCodeStart":878,"sourceCodeEnd":914,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dhcp/DhcpServer.cs#L878-L914","documentation":"Reverse-DNS counterpart of the forward-zone error. DhcpServer computes the reverse zone from the scope address/subnet (Zone.GetReverseZone) and refuses to update an existing reverse AuthZone whose type is not Primary or Forwarder. Only fires when reverseZoneInfo.Name equals the computed reverse zone name.","triggerScenarios":"Enabling a scope where the reverse zone (e.g. '1.168.192.in-addr.arpa') already exists with Type other than Primary/Forwarder AND its name matches Zone.GetReverseZone(address, subnetMask).","commonSituations":"A Secondary reverse zone was imported/created for the same subnet. Reverse zone type changed to Stub/Cache. Migrating configs where reverse zones ended up non-writable.","solutions":["Convert the existing reverse zone (in-addr.arpa) to Primary or Forwarder, then re-enable the scope.","Delete the non-Primary reverse zone so DHCP can auto-create one.","Re-scope the address range so the computed reverse zone name does not collide."],"exampleFix":"// before: reverse zone '1.168.192.in-addr.arpa' is Secondary\n// after\n_dnsServer.AuthZoneManager.SetZoneType('1.168.192.in-addr.arpa', AuthZoneType.Primary);\n_dhcpServer.EnableScope('lan');","handlingStrategy":"validation","validationCode":"string rz = Zone.GetReverseZone(scope.StartingAddress, scope.SubnetMask);\nvar zone = _dnsServer.AuthZoneManager.GetZone(rz);\nif (zone != null && zone.Type != AuthZoneType.Primary && zone.Type != AuthZoneType.Forwarder)\n    throw new InvalidOperationException($\"Reverse zone '{rz}' is {zone.Type}; convert to Primary/Forwarder.\");","typeGuard":"static bool ReverseZoneWritable(AuthZoneInfo z) => z == null || z.Type == AuthZoneType.Primary || z.Type == AuthZoneType.Forwarder;","tryCatchPattern":"try { _dhcpServer.EnableScope(scope.Name); }\ncatch (DhcpServerException ex) when (ex.Message.Contains(\"reverse DNS zone\") && ex.Message.Contains(\"not a primary or a forwarder zone\"))\n{ /* fix reverse zone type, retry */ }","preventionTips":["Manage reverse zones for DHCP subnets as Primary.","Compute the expected reverse zone name and pre-check its type.","Avoid importing Secondary reverse zones over in-use subnets."],"tags":["dhcp","dns","zone-type","reverse-dns","configuration"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}