{"record":{"id":"dc8ff3c754003b86","repo":"lima-vm/lima","slug":"invalid-ip-address-v","errorCode":null,"errorMessage":"invalid IP address: %v","messagePattern":"invalid IP address: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/network.go","lineNumber":228,"sourceCode":"\t\t}\n\t\tyq := fmt.Sprintf(`.networks.%q = {\"mode\":%q,\"interface\":%q}`, name, mode, intf)\n\t\treturn networkApplyYQ(ctx, yq)\n\tdefault:\n\t\tif gateway == \"\" {\n\t\t\treturn fmt.Errorf(\"network mode %#q requires specifying gateway\", mode)\n\t\t}\n\t\tif intf != \"\" {\n\t\t\treturn fmt.Errorf(\"network mode %#q does not support specifying interface\", mode)\n\t\t}\n\t\tif !strings.Contains(gateway, \"/\") {\n\t\t\tgateway += \"/24\"\n\t\t}\n\t\tgwIP, gwMask, err := net.ParseCIDR(gateway)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to parse CIDR %#q: %w\", gateway, err)\n\t\t}\n\t\tif gwIP.IsUnspecified() || gwIP.IsLoopback() {\n\t\t\treturn fmt.Errorf(\"invalid IP address: %v\", gwIP)\n\t\t}\n\t\tgwMaskStr := \"255.255.255.0\"\n\t\tif gwMask != nil {\n\t\t\tgwMaskStr = net.IP(gwMask.Mask).String()\n\t\t}\n\t\t// TODO: check IP range collision\n\n\t\tyq := fmt.Sprintf(`.networks.%q = {\"mode\":%q,\"gateway\":%q,\"netmask\":%q,\"interface\":%q}`, name, mode, gwIP.String(), gwMaskStr, intf)\n\t\treturn networkApplyYQ(ctx, yq)\n\t}\n}\n\nfunc networkApplyYQ(ctx context.Context, yq string) error {\n\tfilePath, err := networks.ConfigFile()\n\tif err != nil {\n\t\treturn err\n\t}\n\tyContent, err := os.ReadFile(filePath)","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/network.go#L210-L246","documentation":"After the gateway CIDR parses, Lima rejects unspecified (0.0.0.0 or ::) and loopback (127.x.x.x, ::1) addresses because a gateway in those ranges cannot be a usable network gateway. The check runs on the parsed gwIP before the networks.yaml entry is written.","triggerScenarios":"Running `limactl network create <name> --gateway 0.0.0.0` (or `127.0.0.1`, `::`, `::1`) with a non-bridged mode.","commonSituations":"Placeholder gateway values left in scripts; misunderstanding loopback as a valid internal gateway; templated configs with a default 0.0.0.0 gateway never filled in.","solutions":["Use a real routable/private gateway IP such as 192.168.5.1 or 10.0.2.1","Remove 0.0.0.0/loopback placeholders from scripts and substitute an actual subnet gateway","If DHCP/bridged behavior was intended, switch to --mode bridged --interface <if> instead"],"exampleFix":"// before\nlimactl network create mynet --gateway 127.0.0.1\n// after\nlimactl network create mynet --gateway 192.168.5.1","handlingStrategy":"validation","validationCode":"gw=\"192.168.104.1\"\npython3 - <<EOF\nimport ipaddress\nip = ipaddress.ip_interface(\"$gw/24\").ip\nassert not ip.is_unspecified and not ip.is_loopback, \"gateway must not be 0.0.0.0/loopback\"\nEOF","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never use 0.0.0.0, ::, or 127.0.0.1 as a gateway","Pick gateways inside a private subnet you control (RFC1918)","Reject placeholder values in provisioning scripts"],"tags":["network","ip-validation","gateway"],"backgroundTag":"invalid-gateway-address","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}