如何获取在无头模式下运行的 VirtualBox VM 的桥接 IP 地址?

Jon*_*dad 29 remote-access virtualbox

我在服务器上设置了 VirtualBox。它被设置为桥接虚拟机,并有一个 IP 地址。它现在以无头模式运行,从“VBoxHeadless -s PuppetMaster”开始。

如何找出 VM 使用 VBoxManage 的 IP?

Alb*_*rto 22

我可以通过以下命令的组合找到我的 Headless VB:

# Update arp table
for i in {1..254}; do ping -c 1 192.168.178.$i & done

# Find vm name
VBoxManage list runningvms

# Find MAC: subsitute vmname with your vm's name
VBoxManage showvminfo vmname

# Find IP: substitute vname-mac-addr with your vm's mac address in ':' notation
arp -a | grep vmname-mac-addr
Run Code Online (Sandbox Code Playgroud)

但更简单:在 linux 中,您可以连接到 VB:

# Default VirtualBox Listening Port: 3389
rdesktop -N hostingserver:3389
Run Code Online (Sandbox Code Playgroud)

此命令将打开一个 shell 窗口,您将可以直接访问 Headless VB,在那里您可以检索您的 Headless VB IP: ip addr


小智 6

安装来宾添加和(假设 linux 是来宾)您可以运行以下命令:

VBoxManage --nologo guestcontrol yourVirtualMachineName execute --image "/sbin/ifconfig"  --username yourUser --password yourPassword --wait-exit --wait-stdout -- -a
Run Code Online (Sandbox Code Playgroud)


and*_*dol 3

不确定 VBoxManage 是否可以直接向您提供该信息。您可以运行以下命令来查看网卡配置。

VBoxManage showvminfo PuppetMaster | egrep ^NIC
Run Code Online (Sandbox Code Playgroud)

如果没有其他方法的话,这将为您提供 MAC 地址,从而允许您通过其他方式找出实际的 IP 地址。

  • 关于如何从命令行使用 MAC 地址获取 IP 有什么想法吗? (2认同)