TechnitiumSoftware/DnsServer · error · ArgumentException

Boot file name cannot exceed 127 bytes.

Error message

Boot file name cannot exceed 127 bytes.

What it means

Thrown by the BootFileName setter when a non-null value has Length >= 128. DHCP boot file names occupy the 128-byte 'file' field in the message, so values of 128 characters or more are rejected (max 127 usable).

Source

Thrown at DnsServerCore/Dhcp/Scope.cs:2013

        public string ServerHostName
        {
            get { return _serverHostName; }
            set
            {
                if ((value != null) && (value.Length >= 64))
                    throw new ArgumentException("Server host name cannot exceed 63 bytes.");

                _serverHostName = value;
            }
        }

        public string BootFileName
        {
            get { return _bootFileName; }
            set
            {
                if ((value != null) && (value.Length >= 128))
                    throw new ArgumentException("Boot file name cannot exceed 127 bytes.");

                _bootFileName = value;
            }
        }

        public IPAddress RouterAddress
        {
            get { return _routerAddress; }
            set
            {
                ValidateIpv4(value, nameof(RouterAddress));
                _routerAddress = value;
            }
        }

        public bool UseThisDnsServer
        {
            get { return _useThisDnsServer; }

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Use a boot file name (path) of at most 127 characters before assignment.
  2. Store longer paths elsewhere (e.g. an option) and pass a short reference here.
  3. Validate input length in your config/UI layer.
  4. For non-ASCII ensure the UTF-8 byte length stays under 128.

Example fix

// before
scope.BootFileName = bootPath; // may exceed 127

// after
scope.BootFileName = (bootPath == null || bootPath.Length <= 127) ? bootPath : bootPath.Substring(0, 127);
Defensive patterns

Strategy: validation

Validate before calling

if (bootFile != null && Encoding.UTF8.GetByteCount(bootFile) >= 128)
    throw new ConfigurationException("BootFileName must be <= 127 bytes");
scope.BootFileName = bootFile;

Type guard

static bool IsValidBootFileName(string s)
    => s == null || Encoding.UTF8.GetByteCount(s) <= 127;

Try / catch

try { scope.BootFileName = value; }
catch (ArgumentException ex) when (ex.Message.Contains("Boot file name"))
{ /* shorten and retry */ }

Prevention

When it happens

Trigger: Assigning scope.BootFileName = value where value != null && value.Length >= 128. Happens with deeply nested PXE boot paths or absolute paths placed in the field.

Common situations: Config with a full absolute path, templated boot file strings, or unvalidated input that exceeds the DHCP file-field limit.

Related errors


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