lima-vm / lima-vm/lima

[Bug]: HostAgent silent packet drop when mapping explicit IPv6 hostIP without guestIP

Open
#4,979 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
21.9k
Forks
957
Avg merge
2d 6h
Merged PRs (30d)
53

Description

# Description

## Summary:
Lima's port forwarding defaults are currently protocol-blind. When a user explicitly defines an IPv6 hostIP (e.g., ::1) but omits the guestIP, Lima defaults the guestIP to an IPv4 address (127.0.0.1). This creates a protocol mismatch in the HostAgent dialer, causing packets to be dropped and client connections to hang. Additionally, Lima fails to set GuestIPMustBeZero when the guestIP is the IPv6 unspecified address (::), breaking wildcard listener logic.

## Environment:
OS: Windows (WSL2 Driver)

Lima Version: limactl version 2.1.1

Networking: Default user-mode networking

## Steps to Reproduce:

Create a Lima instance with the following port forward configuration:

```yaml
portForwards:
- guestPort: 8080
hostIP: "::1"
hostPort: 8080
```

Start the VM:

```bash
limactl start ipv6.yaml
```

Inside the VM, start a server listening on IPv6:

```bash
python3 -m http.server 8080 --bind ::
```

From the Windows Host, attempt to connect via IPv6:

```bash
curl.exe -I -6 "http://[::1]:8080"
```

## Expected Behavior:
The connection should succeed, or if guestIP is left blank, Lima should default the guestIP to ::1 to match the IPv6 hostIP.

## Actual Behavior:
The curl command hangs indefinitely. limactl logs show that the HostAgent is attempting to dial an IPv4 guestIP (127.0.0.1) for an incoming IPv6 request, resulting in a silent failure/packet drop.

## Root Cause Analysis:
The issue lies in pkg/limayaml/defaults.go within the FillPortForwardDefaults function. Currently, the logic hardcodes 127.0.0.1 as the fallback for GuestIP regardless of the HostIP protocol. This prevents the HostAgent from establishing a valid TCP bridge when IPv6 is explicitly requested on the host side.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.