{"record":{"id":"2ffd43f88141bdb1","repo":"TechnitiumSoftware/DnsServer","slug":"addressfamily-not-supported-2ffd43","errorCode":null,"errorMessage":"AddressFamily not supported.","messagePattern":"AddressFamily not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/Zones/Zone.cs","lineNumber":91,"sourceCode":"\n            switch (address.AddressFamily)\n            {\n                case AddressFamily.InterNetwork:\n                    for (int i = 0; i < addressByteCount; i++)\n                        reverseZone = addressBytes[i] + \".\" + reverseZone;\n\n                    reverseZone += \"in-addr.arpa\";\n                    break;\n\n                case AddressFamily.InterNetworkV6:\n                    for (int i = 0; i < addressByteCount; i++)\n                        reverseZone = (addressBytes[i] & 0x0F).ToString(\"x\") + \".\" + (addressBytes[i] >> 4).ToString(\"x\") + \".\" + reverseZone;\n\n                    reverseZone += \"ip6.arpa\";\n                    break;\n\n                default:\n                    throw new NotSupportedException(\"AddressFamily not supported.\");\n            }\n\n            return reverseZone;\n        }\n\n        #endregion\n\n        #region public\n\n        public virtual void ListAllRecords(List<DnsResourceRecord> records)\n        {\n            foreach (KeyValuePair<DnsResourceRecordType, IReadOnlyList<DnsResourceRecord>> entry in _entries)\n                records.AddRange(entry.Value);\n        }\n\n        public abstract bool ContainsNameServerRecords();\n\n        public abstract bool ContainsDNAMERecord();","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/Zones/Zone.cs#L73-L109","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Validate address.AddressFamily is InterNetwork or InterNetworkV6 before calling GetReverseZone, and skip/ignore unsupported families.","Ensure the upstream code that produces the IPAddress only yields IPv4/IPv6 (filter DNS A/AAAA records).","If you genuinely need another family, extend the switch in Zone.cs to compute its reverse zone."],"exampleFix":"// before\nstring reverseZone = Zone.GetReverseZone(address, maskWidth);\n\n// after\nif (address.AddressFamily == AddressFamily.InterNetwork || address.AddressFamily == AddressFamily.InterNetworkV6)\n    string reverseZone = Zone.GetReverseZone(address, maskWidth);\nelse\n    return; // unsupported address family; skip reverse-zone creation","handlingStrategy":"validation","validationCode":"if (address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork &&\n    address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetworkV6)\n{\n    // skip reverse-zone creation for unsupported families\n    return;\n}\nstring reverseZone = Zone.GetReverseZone(address, maskWidth);","typeGuard":"static bool IsSupportedAddressFamily(System.Net.IPAddress address) =>\n    address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork ||\n    address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6;","tryCatchPattern":"null","preventionTips":["Filter DNS records down to A/AAAA before deriving reverse zones.","Never feed IPAddress objects constructed from non-IPv4/IPv6 byte arrays into GetReverseZone.","Unit-test reverse-zone helpers with both IPv4 and IPv6 inputs."],"tags":["dns-server","technitium","ipv6","reverse-zone","input-validation","csharp"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}