TechnitiumSoftware/DnsServer · error · ArgumentException

Address family not supported.

Error message

Address family not supported.

What it means

Constructor argument guard in DhcpMessage: the ciaddr (client IP address) field must be IPv4 (AddressFamily.InterNetwork). DHCP (RFC 2131) is an IPv4-only protocol; the 4-octet ciaddr slot in the wire format has no room for an IPv6 address, so any non-IPv4 IPAddress is rejected. Note this is the manual DhcpMessage builder constructor, not the packet parser.

Source

Thrown at DnsServerCore/Dhcp/DhcpMessage.cs:99

        DhcpMessageTypeOption _dhcpMessageType;
        VendorClassIdentifierOption _vendorClassIdentifier;
        ClientIdentifierOption _clientIdentifier;
        ClientIdentifierOption _clientHardwareIdentifier;
        HostNameOption _hostName;
        ClientFullyQualifiedDomainNameOption _clientFullyQualifiedDomainName;
        ParameterRequestListOption _parameterRequestList;
        MaximumDhcpMessageSizeOption _maximumDhcpMessageSize;
        ServerIdentifierOption _serverIdentifier;
        RequestedIpAddressOption _requestedIpAddress;

        #endregion

        #region constructor

        public DhcpMessage(DhcpMessageOpCode op, DhcpMessageHardwareAddressType hardwareAddressType, byte[] xid, byte[] secs, DhcpMessageFlags flags, IPAddress ciaddr, IPAddress yiaddr, IPAddress siaddr, IPAddress giaddr, byte[] clientHardwareAddress, string sname, string file, IReadOnlyCollection<DhcpOption> options)
        {
            if (ciaddr.AddressFamily != AddressFamily.InterNetwork)
                throw new ArgumentException("Address family not supported.", nameof(ciaddr));

            if (yiaddr.AddressFamily != AddressFamily.InterNetwork)
                throw new ArgumentException("Address family not supported.", nameof(yiaddr));

            if (siaddr.AddressFamily != AddressFamily.InterNetwork)
                throw new ArgumentException("Address family not supported.", nameof(siaddr));

            if (giaddr.AddressFamily != AddressFamily.InterNetwork)
                throw new ArgumentException("Address family not supported.", nameof(giaddr));

            ArgumentNullException.ThrowIfNull(clientHardwareAddress);

            if (clientHardwareAddress.Length > 16)
                throw new ArgumentException("Client hardware address cannot exceed 16 bytes.", nameof(clientHardwareAddress));

            if (xid.Length != 4)
                throw new ArgumentException("Transaction ID must be 4 bytes.", nameof(xid));

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Pass only IPv4 IPAddress values for ciaddr (and yiaddr/siaddr/giaddr).
  2. When resolving a name, filter to AddressFamily.InterNetwork.
  3. Map/convert or skip IPv6 addresses before building the DHCP message.
  4. Validate ciaddr.AddressFamily before constructing DhcpMessage.

Example fix

// before
IPAddress ciaddr = IPAddress.Parse("fe80::1"); // IPv6
var msg = new DhcpMessage(op, htype, xid, secs, flags, ciaddr, yiaddr, siaddr, giaddr, chaddr, sname, file, opts); // throws [211]

// after
IPAddress ciaddr = IPAddress.Parse("192.168.1.10"); // IPv4
var msg = new DhcpMessage(op, htype, xid, secs, flags, ciaddr, yiaddr, siaddr, giaddr, chaddr, sname, file, opts);
Defensive patterns

Strategy: validation

Validate before calling

static IPAddress RequireIPv4(IPAddress addr, string name)
{
    if (addr is null) throw new ArgumentNullException(name);
    if (addr.AddressFamily != AddressFamily.InterNetwork)
        throw new ArgumentException("Address must be IPv4 for DHCPv4.", name);
    return addr;
}

RequireIPv4(ciaddr, nameof(ciaddr));
var msg = new DhcpMessage(op, htype, xid, secs, flags, ciaddr, yiaddr, siaddr, giaddr, chaddr, sname, file, opts);

Type guard

static bool IsIPv4(IPAddress addr) =>
    addr is not null && addr.AddressFamily == AddressFamily.InterNetwork;

Prevention

When it happens

Trigger: Calling the DhcpMessage constructor with an IPAddress for ciaddr whose AddressFamily is InterNetworkV6 (or other) — e.g. building a DHCP reply and passing an IPv6 address object for the client address.

Common situations: Mixing IPv6 address objects into DHCPv4 message construction; a helper that resolves names and returns IPv6 addresses by default; code shared between DHCPv4 and (future) DHCPv6 paths passing the wrong family.

Related errors


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