TechnitiumSoftware/DnsServer · error · InvalidDataException
DnsServer block list zone file format is invalid.
Error message
DnsServer block list zone file format is invalid.
What it means
Thrown when loading a block-list zone config file whose first 2 bytes are not the ASCII magic 'BL'. ReadConfigFrom reads a fixed 2-byte format header before the version byte; any other content (truncated file, wrong file, text/corruption) is treated as an invalid block-list format.
Source
Thrown at DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs:235
_dnsServer.LogManager.Write("DNS Server block list config file was saved: " + blockListConfigFile);
}
public void SaveConfigFile()
{
lock (_saveLock)
{
if (_pendingSave)
return;
_pendingSave = true;
_saveTimer.Change(SAVE_TIMER_INITIAL_INTERVAL, Timeout.Infinite);
}
}
private void ReadConfigFrom(Stream s, bool isConfigTransfer)
{
if (Encoding.ASCII.GetString(s.ReadExactly(2)) != "BL") //format
throw new InvalidDataException("DnsServer block list zone file format is invalid.");
BinaryReader bR = new BinaryReader(s);
byte version = bR.ReadByte();
switch (version)
{
case 1:
int count = bR.ReadByte();
string[] blockListUrls = new string[count];
for (int i = 0; i < count; i++)
blockListUrls[i] = s.ReadShortString();
_blockListUpdateIntervalHours = bR.ReadInt32();
DateTime blockListLastUpdatedOn = s.ReadDateTime();
if (!isConfigTransfer)
_blockListLastUpdatedOn = blockListLastUpdatedOn;View on GitHub (pinned to d0484b6c1e)
Solutions
- Move the offending block-list config file aside and let the server regenerate it (it recreates a valid 'BL' file on next save).
- Restore the file from a known-good backup if you need the previously configured block list URLs.
- Confirm only the block-list file (not a different feature's .bin) lives in the expected path.
Example fix
// before: config/blockListZone.bin has wrong header -> startup of block list fails // after: remove so it regenerates // mv config/blockListZone.bin config/blockListZone.bin.bak (then restart server)
Defensive patterns
Strategy: validation
Validate before calling
static bool IsValidBlockListFile(string path)
{
using var fs = File.OpenRead(path);
Span<byte> hdr = stackalloc byte[2];
return fs.Read(hdr) == 2 && hdr[0] == (byte)'B' && hdr[1] == (byte)'L';
} Try / catch
try { blockListZoneManager.Load(); }
catch (InvalidDataException ex) when (ex.Message.Contains("block list zone file format"))
{ File.Move(blockListPath, blockListPath + ".bad"); blockListZoneManager.Load(); } Prevention
- Validate the 2-byte 'BL' header before loading.
- Keep backups of feature config files separate by feature.
- Let the server regenerate the file rather than hand-editing binary configs.
- Stop the server cleanly so partial writes cannot truncate config files.
When it happens
Trigger: Pointing BlockListZoneManager at a non-blocklist file; a truncated or zero-length file; a file from a different feature (e.g. a 'BZ' blocked-zone file); manual edits that clobber the binary header.
Common situations: Backup restore put the wrong .bin into the config folder; disk corruption or partial write during a crash; upgrading across a format change where the old file is mislabeled.
Related errors
- DnsServer block list zone file version not supported.
- DnsServer blocked zone file format is invalid.
- CacheZoneManager format is invalid.
- DnsServer blocked zone file version not supported.
- CacheZoneManager format version not supported: {version}
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/3fe395d618dea09b.
Report an issue: GitHub.