TechnitiumSoftware/DnsServer · error · InvalidDataException

DnsServer allowed zone file version not supported.

Error message

DnsServer allowed zone file version not supported.

What it means

Thrown by AllowedZoneManager.ReadConfigFrom when the 1-byte version field following the 'AZ' magic does not match any version handled by the switch (currently only version 1). It indicates a version mismatch between the config file written by a newer/older build and the running code.

Source

Thrown at DnsServerCore/Dns/ZoneManagers/AllowedZoneManager.cs:218

                case 1:
                    int length = bR.ReadInt32();
                    int i = 0;

                    AuthZoneManager zoneManager = new AuthZoneManager(_dnsServer);

                    zoneManager.LoadSpecialPrimaryZones(delegate ()
                    {
                        if (i++ < length)
                            return s.ReadShortString();

                        return null;
                    }, _soaRecord, _nsRecord);

                    _zoneManager = zoneManager;
                    break;

                default:
                    throw new InvalidDataException("DnsServer allowed zone file version not supported.");
            }
        }

        private void WriteConfigTo(Stream s)
        {
            IReadOnlyList<AuthZoneInfo> allowedZones = _zoneManager.GetAllZones();
            BinaryWriter bW = new BinaryWriter(s);

            bW.Write(Encoding.ASCII.GetBytes("AZ")); //format
            bW.Write((byte)1); //version

            bW.Write(allowedZones.Count);

            foreach (AuthZoneInfo zone in allowedZones)
                s.WriteShortString(zone.Name);
        }

        #endregion

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Upgrade to the Technitium version that wrote the config file (or newer).
  2. Delete the allowed-zones config file to let the current version regenerate it at version 1 (allowed zones will need re-adding).
  3. Migrate config using a matching version before starting the service.

Example fix

// before: older binary reading newer config throws
ReadConfigFrom(fileStream);

// after: reset incompatible config
try { ReadConfigFrom(fileStream); }
catch (InvalidDataException) when (e.Message.Contains("version not supported")) {
    File.Delete(configPath); // regenerate at v1
}
Defensive patterns

Strategy: try-catch

Validate before calling

byte SupportedAllowedZonesVersion(string path)
{
    using var fs = File.OpenRead(path);
    using var br = new BinaryReader(fs);
    return Encoding.ASCII.GetString(br.ReadBytes(2)) == "AZ" ? br.ReadByte() : (byte)0;
}

Try / catch

try { allowedZoneManager.Load(...); }
catch (InvalidDataException ex) when (ex.Message.Contains("version not supported"))
{
    // upgrade/downgrade mismatch: delete and regenerate at v1
    File.Delete(configPath);
}

Prevention

When it happens

Trigger: Loading an allowed-zones config file whose version byte is anything other than 1 — e.g. a file written by a newer Technitium release that bumped the format, or an experimental/different build.

Common situations: Downgrading Technitium to an older version that does not understand a newer config format; running mixed-version binaries in a cluster; importing a config from a different fork.

Related errors


AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13). Data as JSON: /api/errors/451fca4df7cabecb. Report an issue: GitHub.