TechnitiumSoftware/DnsServer · error · NotSupportedException

AddressFamily not supported.

Error message

AddressFamily not supported.

What it means

Thrown inside StatCounter's client-subnet aggregation when an IPAddress in _clientIpAddressesUdpTcp has an AddressFamily other than InterNetwork (IPv4) or InterNetworkV6 (IPv6). The aggregation maps clients to subnets for the dashboard and only knows how to compute prefixes for those two families; any other family (rare for DNS clients) is rejected rather than silently dropped.

Source

Thrown at DnsServerCore/Dns/StatsManager.cs:2667

                    {
                        case AddressFamily.InterNetwork:
                            IPAddress clientIPv4 = item.Key;

                            foreach (int ipv4Prefix in ipv4Prefixes)
                                UpdateClientSubnetStats(new NetworkAddress(clientIPv4, (byte)ipv4Prefix), item.Value);

                            break;

                        case AddressFamily.InterNetworkV6:
                            IPAddress clientIPv6 = item.Key;

                            foreach (int ipv6Prefix in ipv6Prefixes)
                                UpdateClientSubnetStats(new NetworkAddress(clientIPv6, (byte)ipv6Prefix), item.Value);

                            break;

                        default:
                            throw new NotSupportedException("AddressFamily not supported.");
                    }
                }

                return clientSubnetStats;
            }

            #endregion

            #region properties

            public bool IsLocked
            { get { return _locked; } }

            public long TotalQueries
            { get { return _totalQueries; } }

            public long TotalNoError
            { get { return _totalNoError; } }

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. If hit, inspect _clientIpAddressesUdpTcp for an entry with an unexpected AddressFamily; the stats file likely contains a corrupt IPAddress from a partial write.
  2. Delete the affected .stat file to clear the bad entry; subsequent stats will only contain valid IPv4/IPv6 clients.
  3. If a custom App/transport is recording non-IPv4/IPv6 endpoints, filter them before they enter the stats counters.
Defensive patterns

Strategy: validation

Validate before calling

// Filter to IPv4/IPv6 before aggregating client subnets.
foreach (var kv in clientIpAddressesUdpTcp)
{
    if (kv.Key.AddressFamily != AddressFamily.InterNetwork &&
        kv.Key.AddressFamily != AddressFamily.InterNetworkV6)
        continue; // skip non-IPv4/IPv6 endpoints
    // ... aggregate
}

Type guard

static bool IsSupportedClientAddress(IPAddress ip) =>
    ip.AddressFamily == AddressFamily.InterNetwork ||
    ip.AddressFamily == AddressFamily.InterNetworkV6;

Try / catch

try { stats = counter.GetClientSubnetStats(prefixes); }
catch (NotSupportedException ex) when (ex.Message == "AddressFamily not supported.")
{ /* indicates a corrupt IPAddress in stats; clear the affected .stat file */ }

Prevention

When it happens

Trigger: A client IPAddress recorded in stats whose AddressFamily is neither InterNetwork nor InterNetworkV6 (e.g. InterNetworkV6 is the only non-v4 family normally seen; this would require an exotic family like AppleTalk, or a malformed/corrupt IPAddress entry). Triggered when building client-subnet stats for the dashboard.

Common situations: In practice unreachable for normal DNS traffic, which is IPv4/IPv6 only; would indicate a corrupted IPAddress entry in stats or a custom transport injecting a non-IP endpoint. Essentially a defensive guard.

Related errors


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