TechnitiumSoftware/DnsServer · error · ArgumentOutOfRangeException
Invalid EDNS UDP payload size: valid range is 512-4096 bytes
Error message
Invalid EDNS UDP payload size: valid range is 512-4096 bytes.
What it means
Thrown by the UdpPayloadSize property setter when the value is below 512 or above 4096 bytes. This controls the EDNS(0) UDP payload size advertised in DNS responses; values below 512 would break baseline DNS and values above 4096 risk IP fragmentation issues on the network.
Source
Thrown at DnsServerCore/Dns/DnsServer.cs:7292
else
UdpClientConnection.DisposeSocketPool();
}
catch (Exception ex)
{
_log.Write(ex);
}
});
}
}
}
public ushort UdpPayloadSize
{
get { return _udpPayloadSize; }
set
{
if ((value < 512) || (value > 4096))
throw new ArgumentOutOfRangeException(nameof(UdpPayloadSize), "Invalid EDNS UDP payload size: valid range is 512-4096 bytes.");
_udpPayloadSize = value;
}
}
public bool DnssecValidation
{
get { return _dnssecValidation; }
set
{
if (_dnssecValidation != value)
{
if (!_dnssecValidation)
_cacheZoneManager.Flush(); //flush cache to remove non validated data
_dnssecValidation = value;
}
}View on GitHub (pinned to d0484b6c1e)
Solutions
- Set UdpPayloadSize to a value between 512 and 4096 (1232 is the common recommended value to avoid fragmentation).
- If loading from config, clamp the value before assignment: Math.Clamp(value, 512, 4096).
Example fix
// before server.UdpPayloadSize = 8192; // throws // after server.UdpPayloadSize = 1232; // DNS Flag Day recommended
Defensive patterns
Strategy: validation
Validate before calling
ushort safeSize = (ushort)Math.Clamp(value, 512, 4096); server.UdpPayloadSize = safeSize;
Type guard
static bool IsValidUdpPayloadSize(ushort s) => s >= 512 && s <= 4096;
Try / catch
try { server.UdpPayloadSize = value; }
catch (ArgumentOutOfRangeException) { server.UdpPayloadSize = 1232; } Prevention
- Use the DNS Flag Day recommended value of 1232 to stay safely in range.
- Clamp loaded config values before assignment.
When it happens
Trigger: Setting server.UdpPayloadSize to any ushort value < 512 or > 4096.
Common situations: Tuning for large DNS responses (DNSSEC) by increasing payload; loading a config with an out-of-range value; copying a value from another DNS implementation with different bounds.
Related errors
- EDNS Client Subnet IPv4 prefix length cannot be greater than
- EDNS Client Subnet IPv6 prefix length cannot be greater than
- EDNS Client Subnet IPv4 Override must be an IPv4 network add
- EDNS Client Subnet IPv6 Override must be an IPv6 network add
- Percentage value valid range is between 0 and 100.
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/870556ddb3210448.
Report an issue: GitHub.