How to get IP address assigned to VM running in background?
Solution 1:
You can use the VBoxManage command to extract the IP address, as shown in this forum post on virtualbox.org:
VBoxManage guestproperty enumerate <vmname>
Unless you have very good reasons, though, you'll want to strongly consider assigning a static IP address to your guest vm. This is possible even though you are probably using DHCP. Just pick an IP address outside the range that your DHCP server allocates.
Solution 2:
First at all make sure you have installed VirtualBox Extension Pack or install it if don't.
For example ( for Ubuntu )
> wget http://download.virtualbox.org/virtualbox/4.2.12/Oracle_VM_VirtualBox_Extension_Pack-4.2.12-84980.vbox-extpack
> sudo VBoxManage extpack install ./Oracle_VM_VirtualBox_Extension_Pack-4.2.12-84980.vbox-extpack
or from
https://www.virtualbox.org/wiki/Downloads
After that you can get IP of VM
VBoxManage guestproperty enumerate <_name_of_VM_> | grep IP | grep -o -w -P -e '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
Solution 3:
I know I'm late to this party, but this will work with VirtualBox 5.0.6.
This uses VBoxManage to grab a list of running virtual machines, queries their properties in a loop, and displays the IP addresses in a pretty way.
#!/bin/bash
for f in $(VBoxManage list runningvms | awk -F\" '{print $2}'); do
echo "$f:"
VBoxManage guestproperty enumerate "$f" | grep IP
done