{"record":{"id":"08d849f072994a17","repo":"cloudflare/cloudflared","slug":"invalid-network-cidr","errorCode":null,"errorMessage":"Invalid network CIDR","messagePattern":"Invalid network CIDR","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/tunnel/teamnet_subcommands.go","lineNumber":147,"sourceCode":"}\n\nfunc addRouteCommand(c *cli.Context) error {\n\tsc, err := newSubcommandContext(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif c.NArg() < 2 {\n\t\treturn errors.New(\"You must supply at least 2 arguments, first the network you wish to route (in CIDR form e.g. 1.2.3.4/32) and then the tunnel ID to proxy with\")\n\t}\n\n\targs := c.Args()\n\n\t_, network, err := net.ParseCIDR(args.Get(0))\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Invalid network CIDR\")\n\t}\n\tif network == nil {\n\t\treturn errors.New(\"Invalid network CIDR\")\n\t}\n\n\ttunnelRef := args.Get(1)\n\ttunnelID, err := sc.findID(tunnelRef)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Invalid tunnel\")\n\t}\n\n\tcomment := \"\"\n\tif c.NArg() >= 3 {\n\t\tcomment = args.Get(2)\n\t}\n\n\tvar vnetId *uuid.UUID\n\tif c.IsSet(vnetFlag.Name) {\n\t\tid, err := getVnetId(sc, c.String(vnetFlag.Name))\n\t\tif err != nil {\n\t\t\treturn err","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/tunnel/teamnet_subcommands.go#L129-L165","documentation":"addRouteCommand parses the first positional argument with net.ParseCIDR. If parsing fails (or the parsed network is nil), it wraps the underlying parse error or returns this message, meaning the first argument is not a valid CIDR like 1.2.3.4/32.","triggerScenarios":"Running `cloudflared tunnel route ip add` with a first argument that is a bare IP (e.g. 1.2.3.4 without /32), a hostname, a malformed CIDR (e.g. 10.0.0.0/33), or an empty string.","commonSituations":"Passing a plain IP instead of CIDR notation; typos like /128 on IPv4; Windows shells mangling the slash; copying an IP from output without the prefix length.","solutions":["Append a prefix length: use `1.2.3.4/32` for a single IPv4 or `2001:db8::/64` style for IPv6","Validate the CIDR before running, e.g. `python3 -c \"import ipaddress; ipaddress.ip_network('10.0.0.0/8')\"`","Read the wrapped ParseCIDR error above this message in the output to see the exact parse problem"],"exampleFix":"// before\n$ cloudflared tunnel route ip add 1.2.3.4 my-tunnel\n// error: Invalid network CIDR\n// after\n$ cloudflared tunnel route ip add 1.2.3.4/32 my-tunnel","handlingStrategy":"validation","validationCode":"# validate CIDR before calling the CLI\npython3 -c \"import ipaddress,sys; ipaddress.ip_network(sys.argv[1], strict=False)\" \"$CIDR\" || { echo \"invalid CIDR: $CIDR\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember the argument must be CIDR notation (include /prefix), not a bare IP","Use /32 for a single IPv4 host, /128 for a single IPv6 host","Prefer strict=False semantics in validators to avoid host-bits complaints"],"tags":["cli","cidr","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}