{"record":{"id":"225803a3278fc359","repo":"lima-vm/lima","slug":"network-mode-q-does-not-support-specifying-gatew","errorCode":null,"errorMessage":"network mode %#q does not support specifying gateway","messagePattern":"network mode %#q does not support specifying gateway","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/network.go","lineNumber":206,"sourceCode":"\t\treturn err\n\t}\n\n\tgateway, err := flags.GetString(\"gateway\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tintf, err := flags.GetString(\"interface\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx := cmd.Context()\n\n\tswitch mode {\n\tcase networks.ModeBridged:\n\t\tif gateway != \"\" {\n\t\t\treturn fmt.Errorf(\"network mode %#q does not support specifying gateway\", mode)\n\t\t}\n\t\tif intf == \"\" {\n\t\t\treturn fmt.Errorf(\"network mode %#q requires specifying interface\", mode)\n\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 {","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/network.go#L188-L224","documentation":"In bridged network mode the guest attaches directly to a physical interface, so gateway configuration is not supported; `limactl network create --mode bridged --gateway <ip>` rejects the gateway flag with this error at cmd/limactl/network.go:206. Bridged mode requires --interface instead.","triggerScenarios":"`limactl network create <name> --mode bridged --gateway <ip> ...` — any bridged-mode create that passes a non-empty --gateway value.","commonSituations":"Copy-pasting a create command from a routed/host-network example into a bridged one; assuming gateway/DNS settings apply in bridged mode because the machine has a static gateway config; scripting that always passes --gateway.","solutions":["Drop the --gateway flag for bridged mode: `limactl network create <name> --mode bridged --interface <if>`","Use mode host (or routed) if you actually need to specify a gateway","Set static IPs/gateways inside the guest or via lima.yaml's subnet config rather than the network definition"],"exampleFix":"// before\nlimactl network create br0 --mode bridged --gateway 192.168.1.1 --interface en0\n// after\nlimactl network create br0 --mode bridged --interface en0","handlingStrategy":"validation","validationCode":"MODE=bridged; GW=192.168.1.1\n[ \"$MODE\" = \"bridged\" ] && [ -n \"$GW\" ] && { echo \"bridged mode must not set --gateway\"; exit 1; }","typeGuard":null,"tryCatchPattern":"if err := cmd.Execute(); err != nil {\n\tif strings.Contains(err.Error(), \"does not support specifying gateway\") {\n\t\tfmt.Fprintln(os.Stderr, \"remove --gateway for bridged mode; use --interface\")\n\t\tos.Exit(2)\n\t}\n\tos.Exit(1)\n}","preventionTips":["Remember mode/flag matrix: bridged → interface, no gateway; host/routed → gateway required","Build per-mode command templates in scripts","Avoid passing optional flags unconditionally with empty defaults"],"tags":["network","cli","bridged"],"backgroundTag":"invalid-flag-combination","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}