How do I find the IP address of a virtual machine using VMware Fusion?
VMWare provides, not surprisingly, a built in tool for this, vmrun
. It's under /Applications/VMware Fusion.app/Contents/Library/vmrun
although it has moved around in other Fusion releases a bit.
vmrun list
Total running VMs: 1
.docker/machine/machines/myvm.vmx
vmrun getGuestIPAddress ~/.docker/machine/machines/myvm.vmx
172.16.213.128
Here's a tip in case it helps anyone. Install avahi-daemon
on the VM. This allows you to connect via hostname vmname.local
, where vmname
is the name of your virtual machine. In my case, the VM's name is baremetal
and on the host I can run:
ssh baremetal.local
No need to know the VM's IP. :)
As Mikhail T. said, "Because VMWare is providing the NAT-ing, it ought to be able to tell us, what addresses it is currently NAT-ing for." Indeed it does:
In my VMware Fusion 6 installation, the vmnet-dhcpd
daemon writes its leases to the files /var/db/vmware/vmnet-dhcpd-vmnetX.leases
, where "X" is 1 and 8. Empirically :-) I established that it is vmnet8 that I should look for. Here is an excerpt from the lease file /var/db/vmware/vmnet-dhcpd-vmnet8.leases
:
lease 192.168.177.129 {
starts 1 2014/02/17 09:34:19;
ends 1 2014/02/17 09:36:56;
hardware ethernet 00:0c:29:2b:2b:10;
client-hostname "ubuntu";
}
The client-hostname
is the name of the VM and the number after the word lease
is its IP. You can parse these entries or just simply look at the most recent ones. Make sure the lease you are looking at is still valid.