Is there any possibility to get VMWARE HOST computer name from GUEST workstation without changing things on HOST?

79,034

Solution 1

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

Solution 2

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.....

Solution 3

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.

Solution 4

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...

Solution 5

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.

Share:
79,034
bgee
Author by

bgee

Software Developer of wide variety of Windows\Web\Database applications. Striving to provide clients with professional service including building of robust design leading to development of working, well tested applications in acceptable time frame and high quality maintenance. Specialties C++ under Windows API with MFC, STL, COM and Multithreading C# (.NET from 1.1 upto 4.0) OOD\OOP with UML and Design Patterns Client\Server based applications .NET (upto 3.5) with C#(WinForms), XML, XSLT Databases (Transact-SQL upto MS SQL Server 2005), Web - DHTML(JS), CSS, ASP(.NET), WebForms, Have occassional experience in Linux\Perl\Python

Updated on July 26, 2020

Comments

  • bgee
    bgee almost 4 years

    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.

  • khagler
    khagler over 11 years
    It's probably better to provide a link rather than assuming people will end up the same place you had in mind after Googling.
  • Markus
    Markus over 9 years
    Without having tried this thoroughly: The "new" command seems to be vmware-rpctool 'machine.id.get' under Linux
  • user2506891
    user2506891 about 9 years
    I realize that this isn't from the guest OS but if your trying to get that information from the a VM Guest Host then your not an admin. You should have access to vSphere via vCenter.