Skip to content

Creating a new bridged network results in an error. #3782

@dharsanb

Description

@dharsanb

Description

When trying to use the command limactl network create to create a bridged network, it results in a error
failed to parse CIDR "/24": invalid CIDR address: /24

I'm assuming the error is here because you cannot add gateway / IP ranges as they are managed outside.

lima/cmd/limactl/network.go

Lines 177 to 207 in bd955e4

switch mode {
case networks.ModeBridged:
if gateway != "" {
return fmt.Errorf("network mode %q does not support specifying gateway", mode)
}
if intf == "" {
return fmt.Errorf("network mode %q requires specifying interface", mode)
}
default:
if gateway == "" {
return fmt.Errorf("network mode %q requires specifying gateway", mode)
}
if intf != "" {
return fmt.Errorf("network mode %q does not support specifying interface", mode)
}
}
if !strings.Contains(gateway, "/") {
gateway += "/24"
}
gwIP, gwMask, err := net.ParseCIDR(gateway)
if err != nil {
return fmt.Errorf("failed to parse CIDR %q: %w", gateway, err)
}
if gwIP.IsUnspecified() || gwIP.IsLoopback() {
return fmt.Errorf("invalid IP address: %v", gwIP)
}
gwMaskStr := "255.255.255.0"
if gwMask != nil {
gwMaskStr = net.IP(gwMask.Mask).String()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/clilimactl CLI user experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions