How can I get the Bridged IP address of a VirtualBox VM running in headless mode?
I have VirtualBox set up on a server. It was set up as a Bridged VM, and has an IP address. It's now running in headless mode, started with "VBoxHeadless -s PuppetMaster".
How can I find out what IP the VM is using VBoxManage?
Solution 1:
I could find my Headless VB with the combination of following commands:
# 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
But even easier: in linux, you can connect to the VB:
# Default VirtualBox Listening Port: 3389
rdesktop -N hostingserver:3389
This command will open a shell window, and you'll have direct access to the Headless VB, where you can retrieve your Headless VB IP: ip addr
Solution 2:
Install guest additions and (assuming linux is the guest) you can run the following:
VBoxManage --nologo guestcontrol yourVirtualMachineName execute --image "/sbin/ifconfig" --username yourUser --password yourPassword --wait-exit --wait-stdout -- -a
Solution 3:
VBoxManage guestproperty enumerate {`VBoxManage list runningvms | awk -F"{" '{print $2}'` | grep IP | awk -F"," '{print $2}' | awk '{print $2}'