Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Lima setting hostResolver.ipv6 #1275

Open
stek29 opened this issue Feb 21, 2025 · 2 comments
Open

Expose Lima setting hostResolver.ipv6 #1275

stek29 opened this issue Feb 21, 2025 · 2 comments

Comments

@stek29
Copy link

stek29 commented Feb 21, 2025

Description

currently hostResolver.ipv6 is never set:

l.HostResolver.Enabled = len(conf.Network.DNSResolvers) == 0
l.HostResolver.Hosts = conf.Network.DNSHosts
if l.HostResolver.Hosts == nil {
l.HostResolver.Hosts = make(map[string]string)
}
if _, ok := l.HostResolver.Hosts["host.docker.internal"]; !ok {
l.HostResolver.Hosts["host.docker.internal"] = "host.lima.internal"
}

however, it's possible to get a somewhat working IPv6 network in container with:

network:
  address: true

docker:
  fixed-cidr-v6: SOME-RANDOM-ULA-CIDR::/48
  ipv6: true

but the DNS won't resolve AAAA records since hostResolver.ipv6 property is not set in the lima config.

would be great to allow setting it from the network settings, or to even set it to true automatically if network.address is set to true in Colima spec.

@stek29
Copy link
Author

stek29 commented Feb 21, 2025

I've ended up going for an ugly workaround for now until this issue is resolved:

#!/usr/bin/env bash
# this is a ugly workaround for https://github.com/abiosoft/colima/issues/1275
# put this in your PATH before the original limactl, for example, in ~/bin/limactl

set -euo pipefail

# Get absolute path of this script to avoid recursion
SCRIPT_PATH="$(realpath "${BASH_SOURCE[0]}")"

# Get the first limactl in path skipping this script itself
ORIGINAL_LIMACTL=$(which -a limactl | while read -r candidate; do
    if [[ "$(realpath "$candidate")" != "$SCRIPT_PATH" ]]; then
        echo "$candidate"
        break
    fi
done)

# check if found and is exacutable
if [[ ! -x "${ORIGINAL_LIMACTL}" ]]; then
    echo "limactl not found" >&2
    exit 1
fi

# check if yq is installed
if ! command -v yq &>/dev/null; then
    echo "yq not found" >&2
    exit 1
fi

# if being run for colima and it's a 'start' command with profile name,
# and if that profile has a vzNAT network in it, then set hostResolver.ipv6 to true
if [[ "${LIMA_HOME:-}" =~ \.colima/_lima$ && "${1:-}" == "start" && -n "${2:-}" ]]; then
    profile_name="$2"
    yaml_path="${LIMA_HOME}/${profile_name}/lima.yaml"
    if [[ -f "$yaml_path" ]] && yq e '.networks[] | select(.vzNAT == true) | length > 0' "$yaml_path" &>/dev/null; then
        echo "[limactl-ipv6-wrapper] patching hostResolver.ipv6 to true" >&2
        yq -i e '.hostResolver.ipv6 |= true' "$yaml_path"
    fi
fi

exec "${ORIGINAL_LIMACTL}" "$@"

but this proves that setting the value should be enough

maybe changing the default isn't the safest option, but allowing the end user to configure this through the Colima settings seems like a good idea to me.

@abiosoft
Copy link
Owner

The config was not available in Lima initially, must've been introduced more recently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants