TechnitiumSoftware/DnsServer · error · FormatException

Network group map contains an invalid network address: {netw

Error message

Network group map contains an invalid network address: {network}

What it means

Thrown while parsing the AdvancedForwardingApp 'networkGroupMap' JSON object. Each key is parsed with NetworkAddress.TryParse expecting a CIDR network; on failure a FormatException is raised during app initialization. Note this app uses FormatException, unlike the InvalidOperationException used by the blocking/Dns64 apps for the same check.

Source

Thrown at Apps/AdvancedForwardingApp/App.cs:147

                return new Tuple<string, ConfigProxyServer>(proxyServer.Name, proxyServer);
            }, out Dictionary<string, ConfigProxyServer>? configProxyServers))
                _configProxyServers = configProxyServers;
            else
                _configProxyServers = null;

            if (jsonConfig.TryReadArrayAsMap("forwarders", delegate (JsonElement jsonForwarder)
            {
                ConfigForwarder forwarder = new ConfigForwarder(jsonForwarder, _configProxyServers);
                return new Tuple<string, ConfigForwarder>(forwarder.Name, forwarder);
            }, out Dictionary<string, ConfigForwarder>? configForwarders))
                _configForwarders = configForwarders;
            else
                _configForwarders = null;

            _networkGroupMap = jsonConfig.ReadObjectAsMap("networkGroupMap", delegate (string network, JsonElement jsonGroup)
            {
                if (!NetworkAddress.TryParse(network, out NetworkAddress networkAddress))
                    throw new FormatException("Network group map contains an invalid network address: " + network);

                return new Tuple<NetworkAddress, string>(networkAddress, jsonGroup.ToString());
            });

            if (jsonConfig.TryReadArrayAsMap("groups", ReadGroup, out Dictionary<string, Group>? groups) && (groups is not null))
            {
                if (_groups is not null)
                {
                    foreach (KeyValuePair<string, Group> group in _groups)
                    {
                        if (!groups.ContainsKey(group.Key))
                            group.Value.Dispose();
                    }
                }

                _groups = groups;
            }
            else

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Fix the 'networkGroupMap' key in dnsApp.config to valid CIDR notation (e.g. '10.0.0.0/24', '::/0').
  2. Use '/32' or '/128' for a single host and remove any ':port' suffix.
  3. Validate all network map keys with a CIDR regex/linter before saving the config.

Example fix

// before (dnsApp.config)
"networkGroupMap": { "10.0.0.1:53": "groupA" }
// after
"networkGroupMap": { "10.0.0.0/24": "groupA" }
Defensive patterns

Strategy: validation

Validate before calling

foreach (string key in networkGroupMapKeys)
{
    if (!NetworkAddress.TryParse(key, out NetworkAddress _))
        throw new FormatException($"'networkGroupMap' key '{key}' is not a valid CIDR network.");
}

Type guard

static bool IsValidCidrKey(string key) => NetworkAddress.TryParse(key, out NetworkAddress _);

Prevention

When it happens

Trigger: Calling the AdvancedForwardingApp initializer with a 'networkGroupMap' key that is not a valid CIDR network address (hostname, bare IP without prefix, malformed CIDR like '10/24', endpoint with a port).

Common situations: Entering a single client IP without '/32'; pasting an endpoint '10.0.0.1:53'; CIDR typo; mixing DNS zone names into the network map.

Related errors


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