{"record":{"id":"7ec065748ee65b8b","repo":"lima-vm/lima","slug":"network-mode-q-does-not-support-specifying-inter","errorCode":null,"errorMessage":"network mode %#q does not support specifying interface","messagePattern":"network mode %#q does not support specifying interface","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/network.go","lineNumber":218,"sourceCode":"\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 {\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)","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/network.go#L200-L236","documentation":"For non-bridged network modes the interface field is derived/generated by Lima, so a user-supplied --interface is rejected. The guard right after the gateway check aborts the create if --interface is set while mode is not bridged.","triggerScenarios":"Running `limactl network create <name> --gateway <cidr> --interface <if>` with --mode anything other than bridged (or default mode).","commonSituations":"Users always adding --interface out of habit from bridged mode; scripts templated for bridged networks reused for gateway-based modes; misunderstanding that interface only applies to bridged mode.","solutions":["Remove the --interface flag for this mode: `limactl network create mynet --gateway 192.168.5.1`","If a specific host interface is needed, use --mode bridged (which requires --interface and forbids --gateway)","Run `limactl network create --help` to confirm mode/flag compatibility"],"exampleFix":"// before\nlimactl network create lima-shared --mode shared --gateway 192.168.104.1 --interface en0\n// after\nlimactl network create lima-shared --mode shared --gateway 192.168.104.1","handlingStrategy":"validation","validationCode":"if [ \"$mode\" = \"bridged\" ]; then\n  require interface\nelse\n  unset interface   # interface is only valid for bridged mode\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only pass --interface together with --mode bridged","Never mix --interface and --gateway in one create call","Keep one script template per mode instead of a shared one"],"tags":["network","cli","flag-conflict"],"backgroundTag":"incompatible-flag-combination","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}