{"record":{"id":"132819f0fc2afd1d","repo":"k3s-io/k3s","slug":"no-ipv4-cidrs-found","errorCode":null,"errorMessage":"no IPv4 CIDRs found","messagePattern":"no IPv4 CIDRs found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/util/net.go","lineNumber":44,"sourceCode":"// JoinIPNets stringifies and joins a list of IP networks with commas.\nfunc JoinIPNets(elems []*net.IPNet) string {\n\tvar strs []string\n\tfor _, elem := range elems {\n\t\tstrs = append(strs, elem.String())\n\t}\n\treturn strings.Join(strs, \",\")\n}\n\n// getFirst4Net returns the first IPv4 network from the list of IP networks.\n// If no IPv4 addresses are found, an error is raised.\nfunc getFirst4Net(elems []*net.IPNet) (*net.IPNet, error) {\n\tfor _, elem := range elems {\n\t\tif elem == nil || elem.IP.To4() == nil {\n\t\t\tcontinue\n\t\t}\n\t\treturn elem, nil\n\t}\n\treturn nil, errors.New(\"no IPv4 CIDRs found\")\n}\n\n// getFirst4 returns the first IPv4 address from the list of IP addresses.\n// If no IPv4 addresses are found, an error is raised.\nfunc getFirst4(elems []net.IP) (net.IP, error) {\n\tfor _, elem := range elems {\n\t\tif elem == nil || elem.To4() == nil {\n\t\t\tcontinue\n\t\t}\n\t\treturn elem, nil\n\t}\n\treturn nil, errors.New(\"no IPv4 address found\")\n}\n\n// GetFirst4String returns the first IPv4 address from a list of IP address strings.\n// If no IPv4 addresses are found, an error is raised.\nfunc GetFirst4String(elems []string) (string, error) {\n\tips := []net.IP{}","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/k3s-io/k3s/blob/6ba341e396edc16b8dcae978a7c5e3ac7ee5606e/pkg/util/net.go#L26-L62","documentation":"getFirst4Net in pkg/util/net.go scans a []*net.IPNet and returns the first IPv4 network; if every element is nil or has a nil To4() (IPv6-only or empty list) it returns 'no IPv4 CIDRs found'. Callers use it to derive the IPv4 service/cluster CIDR from flags like --service-cidr / --cluster-cidr, so the error surfaces at config parsing when no IPv4 range is available.","triggerScenarios":"Starting k3s (or calling the config helpers) with CIDR lists that contain only IPv6 ranges - e.g. --service-cidr=fd00:43::/112 with no IPv4 entry - while the code path being configured requires an IPv4 network (components without IPv6 support, or IPv4-mandatory settings).","commonSituations":"IPv6-only or dual-stack experiments; typos in CIDR flags; flags reordered so the first CIDR is v6 where a v4 is required.","solutions":["Add an IPv4 CIDR to the relevant flag (e.g. --service-cidr=10.43.0.0/16,fd00:43::/112) so an IPv4 entry exists.","If running IPv6-only, ensure the components invoked on this path actually support IPv6 and that their flags are set accordingly.","Validate flags before start: each CIDR must parse via net.ParseCIDR and at least one must be IPv4 where required."],"exampleFix":"# before: IPv6-only, IPv4-requiring path fails\nk3s server --service-cidr=fd00:43::/112\n\n# after: dual-stack list contains an IPv4 CIDR\nk3s server --service-cidr=10.43.0.0/16,fd00:43::/112","handlingStrategy":"validation","validationCode":"// Validate that at least one CIDR is IPv4 before config parsing\nfunc hasIPv4CIDR(cidrs []string) bool {\n    for _, c := range cidrs {\n        _, n, err := net.ParseCIDR(c)\n        if err == nil && n.IP.To4() != nil {\n            return true\n        }\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"no IPv4 CIDRs found\") {\n    // add an IPv4 entry to --service-cidr/--cluster-cidr and restart\n}","preventionTips":["Always include an IPv4 CIDR in service/cluster CIDR flags unless every component is v6-verified.","Lint cluster config flags before deployment.","Remember To4() is nil for IPv6 - test flags with net.ParseCIDR in CI."],"tags":["k3s","network","ipv4","cidr","configuration","dual-stack"],"backgroundTag":null,"analyzedSha":"6ba341e396edc16b8dcae978a7c5e3ac7ee5606e","analyzedAt":"2026-08-15T16:27:54.286Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}