TechnitiumSoftware/DnsServer · error · NotSupportedException

AddressFamily not supported.

Error message

AddressFamily not supported.

What it means

Thrown by Zone.GetReverseZone when the supplied IPAddress.AddressFamily is neither InterNetwork (IPv4) nor InterNetworkV6 (IPv6). The method builds a PTR reverse-DNS zone name by switching on the address family; any other family (e.g. InterNetworkV6 on a non-IP type, AppleTalk, etc.) falls into the default arm and raises NotSupportedException. In practice only an IPAddress that was constructed from a non-IPv4/IPv6 byte representation can reach it.

Source

Thrown at DnsServerCore/Dns/Zones/Zone.cs:91

            switch (address.AddressFamily)
            {
                case AddressFamily.InterNetwork:
                    for (int i = 0; i < addressByteCount; i++)
                        reverseZone = addressBytes[i] + "." + reverseZone;

                    reverseZone += "in-addr.arpa";
                    break;

                case AddressFamily.InterNetworkV6:
                    for (int i = 0; i < addressByteCount; i++)
                        reverseZone = (addressBytes[i] & 0x0F).ToString("x") + "." + (addressBytes[i] >> 4).ToString("x") + "." + reverseZone;

                    reverseZone += "ip6.arpa";
                    break;

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

            return reverseZone;
        }

        #endregion

        #region public

        public virtual void ListAllRecords(List<DnsResourceRecord> records)
        {
            foreach (KeyValuePair<DnsResourceRecordType, IReadOnlyList<DnsResourceRecord>> entry in _entries)
                records.AddRange(entry.Value);
        }

        public abstract bool ContainsNameServerRecords();

        public abstract bool ContainsDNAMERecord();

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Validate address.AddressFamily is InterNetwork or InterNetworkV6 before calling GetReverseZone, and skip/ignore unsupported families.
  2. Ensure the upstream code that produces the IPAddress only yields IPv4/IPv6 (filter DNS A/AAAA records).
  3. If you genuinely need another family, extend the switch in Zone.cs to compute its reverse zone.

Example fix

// before
string reverseZone = Zone.GetReverseZone(address, maskWidth);

// after
if (address.AddressFamily == AddressFamily.InterNetwork || address.AddressFamily == AddressFamily.InterNetworkV6)
    string reverseZone = Zone.GetReverseZone(address, maskWidth);
else
    return; // unsupported address family; skip reverse-zone creation
Defensive patterns

Strategy: validation

Validate before calling

if (address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork &&
    address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetworkV6)
{
    // skip reverse-zone creation for unsupported families
    return;
}
string reverseZone = Zone.GetReverseZone(address, maskWidth);

Type guard

static bool IsSupportedAddressFamily(System.Net.IPAddress address) =>
    address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork ||
    address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6;

Try / catch

null

Prevention

When it happens

Trigger: Calling Zone.GetReverseZone(address, subnetMaskWidth) with an IPAddress whose AddressFamily is not IPv4 or IPv6 (for example an internally-created or malformed IPAddress). This happens in the DNS server when a reverse-zone API or auto-creation routine is handed an address it cannot classify.

Common situations: Passing a hostname-resolved or non-IP value through code that assumed it was always an IP; corrupted address records read from zones; third-party plugins feeding exotic address families; unit tests with stub IPAddress objects.

Related errors


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