Automattic / hostmgr

A tool for managing macOS VM hosts
Mozilla Public License 2.0
9 stars 3 forks source link

The file "dhcpd_leases" couldn't be opened. #80

Open jkmassel opened 8 months ago

jkmassel commented 8 months ago

This is a fun one, because it's not our bug.

macOS re-uses a pretty old part of the OS for handing out IP addresses to VMs – it's the same part of the OS that handles Internet Connection Sharing (so if I have a computer that wants to share your computer's internet connection, your computer will use a DHCP server to hand out a valid address to my machine – same deal here, except it's a VM on the same computer, not a different one).

There are a few workarounds – fiddling with internet connection sharing will often cause it to work eventually, in some cases upgrading the OS fixed it immediately. In others, it's just hosed and starting VMs will consistently fail.

That hasn't happened in production yet, which is super nice, but if it does it'll be annoying to try to fix.

There are no public APIs to accomplish what we're after here (get the IP address of a running VM), so we're stuck with this approach for now.


If we ever really need to, we could ask Apple for the vmnet entitlement and have the VMs receive a DHCP address from the cluster network instead of from the local machine. This dramatically increases complexity though, so it'd be super nice to avoid it.

crazytonyli commented 8 months ago

If the purpose is finding ip address of a VM, I'm wondering if we can use the vm's hostname, like ping builders-Virtual-Machine.local? That of course probably requires vms have unique hostname.