diff --git a/DnsServerCore/Dns/ZoneManagers/CacheZoneManager.cs b/DnsServerCore/Dns/ZoneManagers/CacheZoneManager.cs index 6f1ee632..94c60af9 100644 --- a/DnsServerCore/Dns/ZoneManagers/CacheZoneManager.cs +++ b/DnsServerCore/Dns/ZoneManagers/CacheZoneManager.cs @@ -341,7 +341,20 @@ namespace DnsServerCore.Dns.ZoneManagers { DnsQuestionRecord question = request.Question[0]; - CacheZone zone = _root.FindZone(question.Name, out CacheZone closest, out CacheZone delegation); + CacheZone zone; + CacheZone closest = null; + CacheZone delegation = null; + + if (findClosestNameServers) + { + zone = _root.FindZone(question.Name, out closest, out delegation); + } + else + { + if (!_root.TryGet(question.Name, out zone)) + _ = _root.FindZone(question.Name, out closest, out _); //zone not found; attempt to find closest + } + if (zone is not null) { //zone found