Let's suppose I have VMWARE workstation (guesting Windows and hosted by Windows). Is there any possible way to receive host name of hosting machine? And without changing things on host machine like in this link.
I do this by passing a string from host to guest via machine.id. It does require making a change on the host (in every VM's .vmx file, too), and it doesn't automatically discover the host's hostname, but it works. On the host, with the VM in question powered down, edit the .vmx file for the VM. Find or add a line that looks like:
machine.id = "<string>"
Set <string>
equal to some identifying string that will tell you the name of the server. This could be the hostname, or it could be a shortened version of it, or even some unintelligible code if you prefer, as long as you know what it means. If, however, the .vmx file has a line that sets
isolation.tools.machine.id.get.disable = TRUE
passing a string won't work, so if this line is present you might want to either remove/comment it or set the value to FALSE
.
On the guest OS, if you have VMware Tools installed, you can then do this (for Linux guests):
vmware-guestd --cmd 'machine.id.get'
or (for Windows guests, which I haven't tried):
VMwareService --cmd machine.id.get
I know this is an old thread, however if anyone is still interested "thomas lee"'s answer above works on recent version of VMWare workstation and VMWare fusion. The new command to retrieve the value is
rpctool machine.id.get
Using this in deploying managed VMs for Fusion so that the machine name is auto set at first boot. Thanks Thomas.....
If you are able to install PowerCLI on your guest operating system, you can access some ESX host information by looking up the VM that your script is running on:
Connect-VIServer -Server <myvcenterserver>
$myVM = Get-VM -Name $(dir env:COMPUTERNAME).Value
$myVM.Host.Name
Note: This assumes your guest has the same hostname as the VM name in vCenter.
For Linux guests (the OP stated Windows) I use the pyVmomi Python module to perform a similar lookup.
In principle - no.
However, it is possible that there may exist (or will exist) certain vulnerabilities that allow a malicious guest OS to bypass the VM sandbox. For instance, read up on the Blue Pill. You can also read more details on the researcher's own blog, Invisible Things by Joanna Rutkowska.
Of course, these are just proof of concept, but any security implemented in software is subject to software bugs...
I think there are probably a number of ways to do this, and can think of two off the bat:
One would be to install ViX in the guest, connect to the host without specifying the hostname, (Google "ViX reference" then see "common tasks") then use Vix_CopyFileFromHostToGuest()
to copy the file /etc/vmware/esx.conf
.
Another would be to create some sort of network connection from the guest to the host (I used ssh
but if you don't know the hostname or IP you could still do the ViX connection thing as above and dispatch a job that takes a while) and then say netstat -a
in the guest. The netstat
output will contain the hostname, if it is resolvable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With