是否有可能在不更改 HOST 上的内容的情况下从 GUEST 工作站获取 VMWARE HOST 计算机名称?

发布于 2024-07-20 10:26:20 字数 1552 浏览 14 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

我恋#小黄人 2024-07-27 10:26:20

我通过 machine.id 将字符串从主机传递到来宾来实现此目的。 它确实需要在主机上进行更改(也在每个虚拟机的 .vmx 文件中),并且它不会自动发现主机的主机名,但它可以工作。 在主机上,关闭相关 VM 的电源后,编辑该 VM 的 .vmx 文件。 查找或添加如下行:

machine.id = "<string>"

设置为等于某个标识字符串,该字符串将告诉您服务器的名称。 这可以是主机名,也可以是主机名的缩写版本,如果您愿意,甚至可以是一些难以理解的代码,只要您知道它的含义即可。 但是,如果 .vmx 文件中有一行设置

isolation.tools.machine.id.get.disable = TRUE

传递字符串将不起作用,那么如果存在此行,您可能需要删除/注释它或将值设置为 FALSE

在来宾操作系统上,如果安装了 VMware Tools,则可以执行以下操作(对于 Linux 来宾):

vmware-guestd --cmd 'machine.id.get'

或(对于 Windows 来宾,我还没有尝试过):

VMwareService --cmd machine.id.get

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
标点 2024-07-27 10:26:20

我知道这是一个旧线程,但是如果有人仍然感兴趣,“thomas lee”上面的答案适用于最新版本的 VMWare 工作站VMWare fusion。 用于检索该值的新命令是

rpctool machine.id.get

在为 Fusion 部署托管虚拟机时使用此命令,以便在首次启动时自动设置计算机名称。 谢谢托马斯......

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

世态炎凉 2024-07-27 10:26:20

如果您能够在客户机操作系统上安装 PowerCLI,则可以访问某些 ESX通过查找运行脚本的虚拟机来查找主机信息:

Connect-VIServer -Server <myvcenterserver>

$myVM = Get-VM -Name $(dir env:COMPUTERNAME).Value

$myVM.Host.Name

注意:这假设您的来宾主机与 vCenter 中的虚拟机名称相同。

对于 Linux 来宾(OP 指出 Windows),我使用 pyVmomi Python 模块来执行类似的查找。

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.

慕烟庭风 2024-07-27 10:26:20

原则上-不。

但是,可能存在(或将存在)某些漏洞,允许恶意来宾操作系统绕过虚拟机沙箱。 例如,请阅读Blue Pill。 您还可以在研究人员自己的博客 Joanna 的 Invisible Things 上阅读更多详细信息鲁特科斯卡
当然,这些只是概念证明,但在软件中实现的任何安全性都会受到软件错误的影响......

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

怀念你的温柔 2024-07-27 10:26:20

我认为可能有很多方法可以做到这一点,并且可以立即想到两种:
一种方法是在来宾中安装 ViX,连接到主机而不指定主机名(Google“ViX 参考”然后查看“常见任务”),然后使用 Vix_CopyFileFromHostToGuest() 复制文件 /etc/vmware/esx.conf
另一种方法是创建从访客到主机的某种网络连接(我使用了 ssh 但如果您不知道主机名或 IP,您仍然可以按照上面的方式执行 ViX 连接并调度一项需要一段时间的工作),然后在来宾中说 netstat -anetstat 输出将包含主机名(如果可解析)。

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.

冰雪梦之恋 2024-07-27 10:26:20

您实际上在网络上有两台计算机。 如果您对虚拟网卡使用专用网络/NAT 样式设置之一,则主机具有相当可预测的 IP 地址,因此您可以使用多种远程管理方法中的任何一种来询问它,就像您使用任何其他方法一样。

如果只有一个来宾操作系统,则只需尝试与来宾 IP 地址具有相同前 24 位的每个 IP 地址,就可以省去猜测地址的麻烦。

You have effectively two computers on a network. If you use one of the private network/NAT style set-ups for the virtual NICs, then the host has a fairly predictable IP address, so you could then use any of the many remote admin approaches to ask it just like you would any other.

If there is only the one guest OS, then just trying every IP address with the same leading 24 bits as the guest's IP address would save baking in a guess at an address.

黑色毁心梦 2024-07-27 10:26:20

在 vSphere 中

  1. ,单击您的主机
  2. 单击
  3. “软件”部分中的“配置”选项卡 单击“DNS 和路由”

VMware|vCenter|vSphere 主机配置

In vSphere

  1. Click your host
  2. Click Configuration Tab
  3. In Software Section Click DNS and Routing

VMware|vCenter|vSphere Host Configuration

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文