{"record":{"id":"017c143ba58023d7","repo":"TechnitiumSoftware/DnsServer","slug":"dnsserver-block-list-zone-file-version-not-support","errorCode":null,"errorMessage":"DnsServer block list zone file version not supported.","messagePattern":"DnsServer block list zone file version not supported\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs","lineNumber":276,"sourceCode":"                        ThreadPool.QueueUserWorkItem(delegate (object state)\n                        {\n                            try\n                            {\n                                LoadBlockLists();\n                            }\n                            catch (Exception ex)\n                            {\n                                _dnsServer.LogManager.Write(ex);\n                            }\n                        });\n                    }\n\n                    ApplyBlockListUrls(blockListUrls);\n                    ApplyBlockListUpdateInterval();\n                    break;\n\n                default:\n                    throw new InvalidDataException(\"DnsServer block list zone file version not supported.\");\n            }\n        }\n\n        private void WriteConfigTo(Stream s)\n        {\n            BinaryWriter bW = new BinaryWriter(s);\n\n            bW.Write(Encoding.ASCII.GetBytes(\"BL\")); //format\n            bW.Write((byte)1); //version\n\n            bW.Write(Convert.ToByte(_blockListUrls.Count));\n\n            foreach (string blockListUrl in _blockListUrls)\n                s.WriteShortString(blockListUrl);\n\n            bW.Write(_blockListUpdateIntervalHours);\n            s.WriteDateTime(_blockListLastUpdatedOn);\n        }","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs#L258-L294","documentation":"Thrown by ReadConfigFrom's version switch default case: the block-list config file has a valid 'BL' header but its version byte is not '1' (the only supported writer version). This guards forward/backward incompatibility when a newer server wrote a version this build cannot read.","triggerScenarios":"Downgrading the DNS server to an older build that cannot read a newer block-list file version; a hand-edited file with an arbitrary version byte; file partially rewritten so the version byte is garbage.","commonSituations":"Rolling back a server upgrade; copying config files between servers running different versions; corruption that altered the byte after the header.","solutions":["Upgrade the DNS server to a build that supports the file's version.","Discard the block-list config file so a fresh version-1 file is written on next save, then reconfigure block list URLs.","Restore from a backup written by the same (or older compatible) server version."],"exampleFix":"// before: blockListZone.bin version byte = 2 on an older server -> throws\n// after: delete to regenerate at the supported version\n//   rm config/blockListZone.bin   (reconfigure block list URLs via UI after restart)","handlingStrategy":"validation","validationCode":"static int? ReadBlockListVersion(string path)\n{\n    using var fs = File.OpenRead(path);\n    Span<byte> hdr = stackalloc byte[3];\n    if (fs.Read(hdr) != 3 || hdr[0] != (byte)'B' || hdr[1] != (byte)'L') return null;\n    return hdr[2]; // supported == 1\n}","typeGuard":null,"tryCatchPattern":"try { blockListZoneManager.Load(); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"version not supported\"))\n{ File.Delete(blockListPath); blockListZoneManager.Load(); } // regenerate at v1","preventionTips":["Do not copy block-list config files between servers of different versions.","When downgrading, delete version-tagged config files and reconfigure.","After an upgrade, confirm the writer version matches what older builds support before rollback drills.","Treat an unknown version as regenerate-and-reconfigure, not retry."],"tags":["dns","blocklist","config-file","versioning","serialization"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}