Answers:
我可以通过以下命令的组合找到无头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
但是更简单:在Linux中,您可以连接到VB:
# Default VirtualBox Listening Port: 3389
rdesktop -N hostingserver:3389
此命令将打开一个外壳程序窗口,您将直接访问Headless VB,您可以在其中检索您的Headless VB IP:ip addr
安装来宾添加项,并且(假设linux是来宾),可以运行以下命令:
VBoxManage --nologo guestcontrol yourVirtualMachineName execute --image "/sbin/ifconfig" --username yourUser --password yourPassword --wait-exit --wait-stdout -- -a
VBoxManage guestproperty enumerate {`VBoxManage list runningvms | awk -F"{" '{print $2}'` | grep IP | awk -F"," '{print $2}' | awk '{print $2}'
VBoxManage list runningvms | grep vmname | awk ...
VBoxManage guestproperty get <vm-name> "/VirtualBox/GuestInfo/Net/0/V4/IP" | cut -f2 -d " "
从virtualbox.org论坛-
VBoxManage guestproperty get <vm-name> "/VirtualBox/GuestInfo/Net/0/V4/IP" | cut -f2 -d " "
VBoxManage --nologo guestcontrol yourVirtualMachineName --username yourUser --password yourPassword run -- /sbin/ifconfig -a