Skip to content

Comments

Discover VM IP addresses with mDNS#181

Merged
nirs merged 3 commits intomainfrom
multicast-dns
Feb 23, 2026
Merged

Discover VM IP addresses with mDNS#181
nirs merged 3 commits intomainfrom
multicast-dns

Conversation

@nirs
Copy link
Owner

@nirs nirs commented Feb 22, 2026

Replace the serial log IP hack with mDNS-based discovery. Cloud-init
installs avahi-daemon, which announces the VM hostname via mDNS. The
host resolves {name}-vmnet-helper.local and waits for SSH to become
reachable before reporting the IP.

This eliminates jq, serial console device mapping, and fragile log
parsing. Debug logging (--verbose) shows mDNS and SSH connection
attempts, making boot issues easy to diagnose.

CI

The example runs as root on GitHub Actions to bypass macOS Local Network
Privacy, which blocks mDNS resolution for non-root processes on headless
machines. See actions/runner-images#1042

Testing

Tested with:

  • distro: ubuntu, fedora, alpine
  • drivers: vfkit, krunkit, qemu
  • connections: fd, socket, client
  • network: shared

And configure log level to debug when using -v,--verbose. This helps to
debug issues in the example tool.
Replace the serial log hack that wrote the VM IP address from cloud-init
runcmd with mDNS-based discovery using avahi. This eliminates the need
for jq in the guest, the fragile serial log parsing, and the
per-driver/arch serial console device map (SERIAL_CONSOLE).

Cloud-init now installs avahi-daemon and sets the hostname to
"{name}-vmnet-helper". The host resolves "{name}-vmnet-helper.local" via
mDNS (macOS mDNSResponder) and waits for SSH to become reachable before
reporting the IP address.

Dashes are used in the hostname instead of dots because avahi strips
everything after the first dot and announces only the short name.

The ip-address file is still written for compatibility with bench and
CI. We will remove it in the next step.

Example first start (mDNS not cached, avahi not yet installed):

    % ./example fedora --distro fedora -v
    ...
    [   0.071] INFO Starting 'vfkit' virtual machine 'fedora' ...
    [   5.077] DEBUG mDNS lookup 'fedora-vmnet-helper.local':
               [Errno 8]nodename nor servname provided, or not known
    [  11.082] DEBUG mDNS lookup 'fedora-vmnet-helper.local':
               [Errno 8] nodename nor servname provided, or not known
    [  17.038] INFO Virtual machine IP address: 192.168.105.10

Example second start (mDNS cached, avahi already installed):

    % ./example fedora --distro fedora -v
    ...
    [   0.078] INFO Starting 'vfkit' virtual machine 'fedora' ...
    [   1.085] DEBUG Connect 192.168.105.10:22: timed out
    [   3.092] DEBUG Connect 192.168.105.10:22: timed out
    [   5.101] DEBUG Connect 192.168.105.10:22: timed out
    [   7.107] DEBUG Connect 192.168.105.10:22: timed out
    [   8.112] INFO Virtual machine IP address: 192.168.105.10

Co-authored-by: Cursor <cursoragent@cursor.com>
@nirs nirs force-pushed the multicast-dns branch 3 times, most recently from feeed20 to 607ba44 Compare February 23, 2026 01:12
macOS Local Network Privacy (introduced in Sequoia) blocks access to
local network for non-root processes running outside Terminal. On GitHub
Actions, the example script runs as a launchd agent, which is denied
local network access. Running as root bypasses this restriction.

See actions/runner-images#1042

Co-authored-by: Cursor <cursoragent@cursor.com>
@nirs nirs added this to the v.0.10.0 milestone Feb 23, 2026
@nirs nirs merged commit 52d6c78 into main Feb 23, 2026
12 checks passed
@nirs nirs deleted the multicast-dns branch February 23, 2026 01:53
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

Successfully merging this pull request may close these issues.

1 participant