TechnitiumSoftware/DnsServer · error · ArgumentOutOfRangeException
QPM limit IPv4 prefix valid range is between 0 and 32.
Error message
QPM limit IPv4 prefix valid range is between 0 and 32.
What it means
Thrown by the QpmPrefixLimitsIPv4 property setter when any dictionary key (IPv4 prefix length) is outside 0-32. IPv4 addresses are 32 bits, so prefix lengths beyond that are invalid. Each entry is validated in a loop before assignment.
Source
Thrown at DnsServerCore/Dns/DnsServer.cs:7418
public IReadOnlyDictionary<int, (int, int)> QpmPrefixLimitsIPv4
{
get { return _qpmPrefixLimitsIPv4; }
set
{
if (value is null)
{
_qpmPrefixLimitsIPv4 = new Dictionary<int, (int, int)>();
}
else if (value.Count > byte.MaxValue)
{
throw new ArgumentOutOfRangeException(nameof(QpmPrefixLimitsIPv4), "QPM Prefix Limits for IPv4 cannot have more than 255 entries.");
}
else
{
foreach (KeyValuePair<int, (int, int)> qpmPrefixLimit in value)
{
if ((qpmPrefixLimit.Key < 0) || (qpmPrefixLimit.Key > 32))
throw new ArgumentOutOfRangeException(nameof(QpmPrefixLimitsIPv4), "QPM limit IPv4 prefix valid range is between 0 and 32.");
if ((qpmPrefixLimit.Value.Item1 < 0) || (qpmPrefixLimit.Value.Item2 < 0))
throw new ArgumentOutOfRangeException(nameof(QpmPrefixLimitsIPv4), "QPM limit value cannot be less than 0.");
}
_qpmPrefixLimitsIPv4 = value;
}
ResetQpsLimitTimer();
}
}
public IReadOnlyDictionary<int, (int, int)> QpmPrefixLimitsIPv6
{
get { return _qpmPrefixLimitsIPv6; }
set
{
if (value is null)View on GitHub (pinned to d0484b6c1e)
Solutions
- Ensure all keys are integers in the range 0-32 inclusive.
- Filter the dictionary before assignment to drop out-of-range keys.
Example fix
// before
server.QpmPrefixLimitsIPv4 =
new Dictionary<int,(int,int)> { { 64, (100, 200) } }; // throws
// after
server.QpmPrefixLimitsIPv4 =
new Dictionary<int,(int,int)> { { 24, (100, 200) } }; Defensive patterns
Strategy: validation
Validate before calling
foreach (var key in qpmV4.Keys)
if (key < 0 || key > 32)
throw new InvalidOperationException($"Invalid IPv4 prefix key: {key}");
server.QpmPrefixLimitsIPv4 = qpmV4; Type guard
static bool IsValidV4PrefixKey(int key) => key >= 0 && key <= 32;
Try / catch
try { server.QpmPrefixLimitsIPv4 = qpmV4; }
catch (ArgumentOutOfRangeException) { qpmV4 = qpmV4.Where(kv => kv.Key >= 0 && kv.Key <= 32).ToDictionary(k=>k.Key,v=>v.Value); server.QpmPrefixLimitsIPv4 = qpmV4; } Prevention
- Validate keys are in 0-32 before building the dictionary.
- Do not reuse IPv6 prefix lists for the IPv4 property.
When it happens
Trigger: Assigning QpmPrefixLimitsIPv4 a dictionary containing a key < 0 or > 32.
Common situations: Reusing an IPv6 prefix-length list (up to 128) for the IPv4 limits; off-by-one in generated config; typo in a manually-edited settings file.
Related errors
- QPM Prefix Limits for IPv4 cannot have more than 255 entries
- QPM limit value cannot be less than 0.
- QPM limit IPv6 prefix valid range is between 0 and 128.
- QPM Prefix Limits for IPv6 cannot have more than 255 entries
- Valid range is between 1 and 60 minutes.
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/f80f0835fa55fb52.
Report an issue: GitHub.