26

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?

20

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

6

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
  • 1
    Format changed a bit now, you'll need VBoxManage --nologo guestcontrol yourVirtualMachineName --username yourUser --password yourPassword run -- /sbin/ifconfig -a – mike.dld Aug 5 '16 at 13:37
4
VBoxManage guestproperty enumerate {`VBoxManage list runningvms | awk -F"{" '{print $2}'` | grep IP | awk -F"," '{print $2}' | awk '{print $2}'
  • Command works for a single VM. -- With multiple VMs filter by VM name, e.g.: VBoxManage list runningvms | grep vmname | awk ... – mschuett Jan 4 '13 at 10:22
  • Or we can inquire about a specific VM. e.g. VBoxManage guestproperty get <vm-name> "/VirtualBox/GuestInfo/Net/0/V4/IP" | cut -f2 -d " " – Mohnish Aug 2 '17 at 19:17
3

Not sure if VBoxManage can give you that information directly. What you can do is run the following command to see the network card configuration.

VBoxManage showvminfo PuppetMaster | egrep ^NIC

That will if nothing else will provide you with the MAC address, allowing you to find out the actual ip address by other means.

  • 2
    Any ideas on how to get the IP using the MAC address from the command line? – Jon Haddad Apr 2 '10 at 18:22
2

You can get it directly using this command:

VBoxManage list bridgedifs
1

From virtualbox.org forum --

VBoxManage guestproperty get <vm-name> "/VirtualBox/GuestInfo/Net/0/V4/IP" | cut -f2 -d " "

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.