{"record":{"id":"155dbc17e3d2baad","repo":"Billionmail/BillionMail","slug":"ipv4-network-format-is-incorrect-please-use-cidr","errorCode":null,"errorMessage":"IPv4 network format is incorrect, please use CIDR format (e.g. 192.168.1.0/24)","messagePattern":"IPv4 network format is incorrect, please use CIDR format \\(e\\.g\\. 192\\.168\\.1\\.0/24\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/controller/settings/settings.go","lineNumber":222,"sourceCode":"\n\tcase \"BILLIONMAIL_HOSTNAME\", \"billionmail_hostname\":\n\t\t// Hostname: allowed letters, numbers, dots, hyphens\n\t\tif !public.IsValidHostname(value) {\n\t\t\treturn fmt.Errorf(\"hostname format is incorrect\")\n\t\t}\n\n\tcase \"SMTP_PORT\", \"SMTPS_PORT\", \"SUBMISSION_PORT\", \"IMAP_PORT\", \"IMAPS_PORT\", \"POP_PORT\", \"POPS_PORT\", \"HTTP_PORT\", \"HTTPS_PORT\", \"REDIS_PORT\",\n\t\t\"smtp\", \"smtps\", \"submission\", \"imap\", \"imaps\", \"pop\", \"pops\", \"http\", \"https\", \"redis_port\":\n\t\t// Port: 1-65535\n\t\tport := public.ParseInt(value)\n\t\tif port < 1 || port > 65535 {\n\t\t\treturn fmt.Errorf(\"port must be between 1-65535\")\n\t\t}\n\n\tcase \"IPV4_NETWORK\", \"ipv4_network\":\n\t\t// IPv4 network: CIDR format\n\t\tif !public.IsValidCIDR(value) {\n\t\t\treturn fmt.Errorf(\"IPv4 network format is incorrect, please use CIDR format (e.g. 192.168.1.0/24)\")\n\t\t}\n\n\tcase \"TZ\", \"timezone\":\n\t\t// Timezone: check if it is a valid timezone\n\t\tif !public.IsValidTimezone(value) {\n\t\t\treturn fmt.Errorf(\"invalid timezone\")\n\t\t}\n\n\tcase \"FAIL2BAN_INIT\", \"fail2ban\":\n\t\t// fail2ban: only allowed y/n or 1/0\n\t\tif value != \"y\" && value != \"n\" && value != \"1\" && value != \"0\" {\n\t\t\treturn fmt.Errorf(\"fail2ban value can only be y/n or 1/0\")\n\t\t}\n\tcase \"RETENTION_DAYS\", \"retention_days\":\n\t\t// retention_days: must be a number\n\t\tif _, err := strconv.Atoi(value); err != nil {\n\t\t\treturn fmt.Errorf(\"retention_days must be a number\")\n\t\t}","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/controller/settings/settings.go#L204-L240","documentation":"validateConfigValue validates the IPV4_NETWORK key with public.IsValidCIDR and rejects values that are not valid IPv4 CIDR notation. This network is written into Docker/mail-service network configuration, so a malformed value would break container networking. An example is embedded in the message.","triggerScenarios":"Setting IPV4_NETWORK to a bare IP (192.168.1.0), an IPv6 value, a netmask form (255.255.255.0), a range with a hyphen, or an incorrect prefix length (192.168.1.0/33).","commonSituations":"Users confuse netmask with CIDR prefix, omit the /prefix, or paste the Docker subnet with extra whitespace or a gateway address instead of the network address.","solutions":["Use CIDR format with network address and prefix, e.g. 192.168.1.0/24","Convert a netmask to a prefix length (255.255.255.0 → /24)","Validate with a CIDR parser (Go net.ParseCIDR) before calling the API","Match the existing Docker network subnet if one is already deployed"],"exampleFix":"// before\nIPV4_NETWORK = 192.168.1.0\n// after\nIPV4_NETWORK = 192.168.1.0/24","handlingStrategy":"validation","validationCode":"function isValidCIDR(v: string): boolean {\n  const m = v.match(/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\/(\\d{1,2})$/);\n  if (!m) return false;\n  const ok = [1,2,3,4].every(i => +m[i] >= 0 && +m[i] <= 255);\n  return ok && +m[5] <= 32;\n}\nif (!isValidCIDR(network)) throw new Error('use CIDR, e.g. 192.168.1.0/24');","typeGuard":"function isCIDR(v: string): boolean {\n  return /^\\d{1,3}(\\.\\d{1,3}){3}\\/(\\d|[12]\\d|3[0-2])$/.test(v);\n}","tryCatchPattern":"try {\n  await api.setSystemConfigKey('IPV4_NETWORK', network);\n} catch (e) {\n  if (String(e.message).includes('CIDR')) {\n    notify('IPv4 network must be in CIDR format, e.g. 192.168.1.0/24');\n  } else throw e;\n}","preventionTips":["Always include the /prefix length","Convert netmasks to prefix lengths before submitting","Use the network address, not the gateway or broadcast address","Reuse an existing Docker subnet if one is already provisioned"],"tags":["validation","config","network","cidr"],"backgroundTag":"invalid-cidr-notation","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}