Skip to content

Conversation

@norio-nomura
Copy link
Contributor

@norio-nomura norio-nomura commented Nov 1, 2025

This change allows resolving <guest's hostname>.local to guest ip by mDNS on macOS host.

e.g.

$ limactl start --name shared-and-vznat --tty=false --network=lima:shared,vzNAT --containerd=none --log-level error
...
$ dns-sd -q lima-shared-and-vznat.local
DATE: ---Sat 01 Nov 2025---
15:31:14.555  ...STARTING...
Timestamp     A/R  Flags         IF  Name                          Type   Class  Rdata
15:31:14.555  Add  40000003      27  lima-shared-and-vznat.local.  Addr   IN     192.168.64.2
15:31:14.555  Add  40000002      31  lima-shared-and-vznat.local.  Addr   IN     192.168.105.3
^C
$ ping -c 1 lima-shared-and-vznat.local
PING lima-shared-and-vznat.local (192.168.64.2): 56 data bytes
64 bytes from 192.168.64.2: icmp_seq=0 ttl=64 time=0.568 ms

--- lima-shared-and-vznat.local ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.568/0.568/0.568/0.000 ms

This change allows resolving `<guest's hostname>.local` to guest ip by mDNS on macOS host.

e.g.
```console
$ limactl start --name shared-and-vznat --tty=false --network=lima:shared,vzNAT --containerd=none --log-level error
...
$ dns-sd -q lima-shared-and-vznat.local
DATE: ---Sat 01 Nov 2025---
15:31:14.555  ...STARTING...
Timestamp     A/R  Flags         IF  Name                          Type   Class  Rdata
15:31:14.555  Add  40000003      27  lima-shared-and-vznat.local.  Addr   IN     192.168.64.2
15:31:14.555  Add  40000002      31  lima-shared-and-vznat.local.  Addr   IN     192.168.105.3
^C
$ ping -c 1 lima-shared-and-vznat.local
PING lima-shared-and-vznat.local (192.168.64.2): 56 data bytes
64 bytes from 192.168.64.2: icmp_seq=0 ttl=64 time=0.568 ms

--- lima-shared-and-vznat.local ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.568/0.568/0.568/0.000 ms
```

Signed-off-by: Norio Nomura <[email protected]>
@norio-nomura norio-nomura force-pushed the enable-mDNS-in-guest-using-systemd-on-macOS-host branch from f7797d5 to 4584ef8 Compare November 1, 2025 07:01
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this work with other drivers with lima:shared ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works.

$ limactl start --name bridged --tty=false --network=lima:bridged --containerd=none --log-level=error
...
$ ping -c 1 lima-bridged.local
PING lima-bridged.local (192.168.12.43): 56 data bytes
64 bytes from 192.168.12.43: icmp_seq=0 ttl=64 time=1.068 ms

--- lima-bridged.local ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 1.068/1.068/1.068/nan ms
$ limactl start --name host-only --tty=false --network=lima:host --containerd=none --log-level=error
...
$ ping -c 1 lima-host-only.local
PING lima-host-only.local (192.168.106.2): 56 data bytes
64 bytes from 192.168.106.2: icmp_seq=0 ttl=64 time=1.090 ms

--- lima-host-only.local ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 1.090/1.090/1.090/nan ms

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work with QEMU, krunkit, and other potential drivers too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, PR's title was not correct. Fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll test with other drivers on macOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works with qemu and krunkit.

$ ping -c 1 lima-qemu.local
PING lima-qemu.local (192.168.105.6): 56 data bytes
64 bytes from 192.168.105.6: icmp_seq=0 ttl=64 time=0.748 ms

--- lima-qemu.local ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.748/0.748/0.748/0.000 ms
$ ping -c 1 lima-krunkit.local
PING lima-krunkit.local (192.168.105.5): 56 data bytes
64 bytes from 192.168.105.5: icmp_seq=0 ttl=64 time=1.005 ms

--- lima-krunkit.local ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 1.005/1.005/1.005/nan ms

Is there already a way to limit the execution of the boot script by the host OS?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script shouldn't care about the host OS. There should be a CIDATA variable that indicates the existence of IP-reachable network.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first, I tried to enable mDNS on the corresponding interface when Direct IP was detected, not as a boot script.
However, if there is no mDNS environment on the host OS side, I thought it would be meaningless to enable it, so I wanted to limit it to macOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved 06-enable-mdns-on-systemd.sh from pkg/driver/vz to pkg/cidata.

@norio-nomura norio-nomura changed the title pkg/driver/vz: Enable mDNS in guest using systemd on macOS host pkg/driver/vz: Enable mDNS in guest using systemd on VZ Nov 1, 2025
@norio-nomura norio-nomura changed the title pkg/driver/vz: Enable mDNS in guest using systemd on VZ pkg/cidata: Enable mDNS in guest using systemd Nov 2, 2025
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Nov 2, 2025
@AkihiroSuda AkihiroSuda merged commit cc9fca7 into lima-vm:master Nov 2, 2025
89 of 91 checks passed
@norio-nomura norio-nomura deleted the enable-mDNS-in-guest-using-systemd-on-macOS-host branch November 2, 2025 09:09
@norio-nomura
Copy link
Contributor Author

Thanks! 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants