Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I run my Ubuntu instance out of Virtual Box in the background using the following command:

VBoxManage startvm ${VM_NAME} --type headless

The main difference between that and running it through the GUI is that, when I am in the GUI after it starts, I can check ifconfig to see what the IP address is so that I can ssh into it from my terminal on the host and obviously can't do that in the background.

Assuming a dynamic assignment of IP addresses on the network, is there a way to extract the assigned IP to the newly created instance for ssh purposes OR is there a way to ssh into it without knowing the IP (e.g. via a backdoor port on the host)?

share|improve this question
add comment

2 Answers 2

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.

share|improve this answer
    
that command did not return the IP address –  amphibient Aug 20 '13 at 14:01
    
You need to have the guest additions installed for this to work. –  heavyd Aug 20 '13 at 14:42
add comment

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}'
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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