Note this works only when the VMs have VMware Tools installed (more on that below):
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
via: How do I find the IP address of a virtual machine using VMware Fusion? – Super User [WayBack]
vmrun [WayBack] is barely documented and most of is in PDF of which this is the most recent I could find: www.vmware.com/pdf/vix180_vmrun_command.pdf [WayBack]
Based on the above path, I added this to my ~/.bash_profile
file:
alias vmrun='/Applications/VMware\ Fusion.app/Contents/Library/vmrun' alias vmrun-list-running-VMs='vmrun list | grep vmx' vmrun-list-ipv4-of-running-VMs() { vmrun-list-running-VMs | while read line ; do echo $line && vmrun getGuestIPAddress $line; done }
Now I can do this:
$ vmrun-list-ipv4-of-running-VMs
/Users/jeroenp/VM/W81Entx64DelphiRegression.vmwarevm/W81Entx64.vmx
172.16.172.135
/Users/jeroenp/VM/diaspore-opensuse-Tumbleweed-x64.vmwarevm/diaspore-opensuse-Tumbleweed-x64.vmx
Error: The VMware Tools are not running in the virtual machine: /Users/jeroenp/VM/diaspore-opensuse-Tumbleweed-x64.vmwarevm/diaspore-opensuse-Tumbleweed-x64.vmx
$ vmrun-list-ipv4-of-running-VMs
/Users/jeroenp/VM/diaspore.opensuse-Tumbleweed-x64/diaspore.opensuse-Tumbleweed-x64.vmx
Error: Unable to get the IP address
/Users/jeroenp/VM/W81Entx64DelphiRegression.vmwarevm/W81Entx64.vmx
172.16.172.135
$ vmrun-list-ipv4-of-running-VMs
/Users/jeroenp/VM/diaspore.opensuse-Tumbleweed-x64/diaspore.opensuse-Tumbleweed-x64.vmx
Error: Unable to get the IP address
/Users/jeroenp/VM/W81Entx64DelphiRegression.vmwarevm/W81Entx64.vmx
172.16.172.135
$ vmrun-list-ipv4-of-running-VMs
/Users/jeroenp/VM/diaspore.opensuse-Tumbleweed-x64/diaspore.opensuse-Tumbleweed-x64.vmx
172.16.172.134
/Users/jeroenp/VM/W81Entx64DelphiRegression.vmwarevm/W81Entx64.vmx
172.16.172.135
$ vmrun-list-ipv4-of-running-VMs
/Users/jeroenp/VM/diaspore.opensuse-Tumbleweed-x64/diaspore.opensuse-Tumbleweed-x64.vmx
172.16.172.134
/Users/jeroenp/VM/W81Entx64DelphiRegression.vmwarevm/W81Entx64.vmx
172.16.172.142
These are the messages I observed:
Error: The VMware Tools are not running in the virtual machine: /Users/jeroenp/VM/diaspore-opensuse-Tumbleweed-x64.vmwarevm/diaspore-opensuse-Tumbleweed-x64.vmx
Error: Unable to get the IP address
172.16.172.135
The first one means a machine is running but has no VMware Tools installed. For an OpenSuSE machine you can install it with zypper install open-vm-tools
, for other Linux systems read VMware Tools auf Ubuntu, Mint, CentOS oder openSUSE installieren | ITrig [WayBack]
Some more examples of vmrun
for VMware Fusion are at Control VMware Fusion from the Command Line | James Reuben Knowles [WayBack]
–jeroen
Filed under: *nix, bash, Development, Fusion, openSuSE, Power User, Scripting, Software Development, SuSE Linux, Tumbleweed, Virtualization, VMware
