TechnitiumSoftware/DnsServer · error · InvalidOperationException

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 AdvancedBlockingApp 'networkGroupMap' JSON object. Each key is parsed with NetworkAddress.TryParse, which expects a CIDR network address (e.g. '192.168.1.0/24' or '::/0'). A key that is not a valid network address raises InvalidOperationException during app initialization.

Source

Thrown at Apps/AdvancedBlockingApp/App.cs:382

            _nsRecord = new DnsNSRecordData(_dnsServer.ServerDomain);

            if (jsonConfig.TryReadObjectAsMap("localEndPointGroupMap",
                delegate (string localEP, JsonElement jsonGroup)
                {
                    if (!EndPointExtensions.TryParse(localEP, out EndPoint ep))
                        throw new InvalidOperationException("Local end point group map contains an invalid end point: " + localEP);

                    return new Tuple<EndPoint, string>(ep, jsonGroup.GetString() ?? "");
                },
                out Dictionary<EndPoint, string>? localEndPointGroupMap))
            {
                _localEndPointGroupMap = localEndPointGroupMap;
            }

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

                return new Tuple<NetworkAddress, string>(networkAddress, jsonGroup.GetString() ?? "");
            });

            {
                Dictionary<Uri, BlockList> allAllowListZones = new Dictionary<Uri, BlockList>(0);
                Dictionary<Uri, BlockList> allBlockListZones = new Dictionary<Uri, BlockList>(0);

                Dictionary<Uri, RegexList> allRegexAllowListZones = new Dictionary<Uri, RegexList>(0);
                Dictionary<Uri, RegexList> allRegexBlockListZones = new Dictionary<Uri, RegexList>(0);

                Dictionary<Uri, AdBlockList> allAdBlockListZones = new Dictionary<Uri, AdBlockList>(0);

                _groups = jsonConfig.ReadArrayAsMap("groups", delegate (JsonElement jsonGroup)
                {
                    Group group = new Group(this, jsonGroup);

                    foreach (Uri allowListUrl in group.AllowListUrls)

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Edit dnsApp.config and correct the 'networkGroupMap' key to valid CIDR notation (e.g. '192.168.1.0/24', 'fe80::/64').
  2. Ensure IPv4 keys carry an explicit prefix length; '/32' for a single host.
  3. Keep endpoints (with ports) out of 'networkGroupMap' — those belong in 'localEndPointGroupMap'.

Example fix

// before (dnsApp.config)
"networkGroupMap": { "192.168.1.5": "groupA" }
// after
"networkGroupMap": { "192.168.1.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. Expected e.g. '192.168.1.0/24'.");
}

Type guard

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

Prevention

When it happens

Trigger: Calling the AdvancedBlockingApp initializer with a 'networkGroupMap' key that NetworkAddress.TryParse rejects: a hostname, a bare host IP with no prefix length in a context requiring CIDR, a typo like '192.168.1.0//24', or an out-of-range octet.

Common situations: Pasting a client IP '10.0.0.5' instead of its subnet '10.0.0.0/24'; using DNS zone notation; trailing slash typos; mixing an endpoint (with ':port') into the network map.

Related errors


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