System: Linux Universal, virtualbox5.0
Each time the VM virtual machine is started with the following command, it is found that there is no way to know its IP.
$ vboxmanage STARTVM <vmname>--type Headless
According to some of Google's commands, also can not find out, so found a foreign buddies to use ARP method to find the online LAN host method to change to a script, currently support a single online virtual machine, I have time to change to a multi-user.
#!/bin/bash
#This shell script can find the IP of running VirtualBox system
#But now (2016/04/18 23:20[beijing]), it is only use to find one running VirtualBox system
#此脚本用户找到birdge方式单台在运行的virtualbox虚拟机ip
Vmname= ' vboxmanage list Runningvms | Awk-f ' "' {print $} '
if [!-n "VMNAME"];then
For i in {100..120}
Do
Ping-c 1 192.168.1. $i &>/dev/null
Done
Vmmac= ' Vboxmanage showvminfo ${vmname} |grep ' MAC ' |awk ' {print $4} ' |awk-f ', ' {print '} ' | Sed-r ' s/^ (. { 2}) (. { 2}) (. { 2}) (. { 2}) (. { 2}) (. { 2})/\1:\2:\3:\4:\5:\6/"
vmip= ' Arp-a | Grep-i $VMMAC |sed ' s/^.* (. *\). *$/\1/"
Echo $VMIP
Else
echo "Enn ..., not have running VirtualBox system."
Fi
Vboxmanage querying a running vbox virtual machine