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 have a VirtualBox guest (running Ubuntu) configured with NAT through my host laptop (running OSX). It was my understanding that with NAT configured, I could access the guest from the host (w/o any port forwarding magic) but not from any outside machine...was I incorrect in thinking that?

I would use bridged networking, but every time I switch networks (@ home, @ work, tethered to my phone), the guest's ip will change, right?

share|improve this question
add comment

3 Answers 3

up vote 15 down vote accepted

If you only need to access the guest from the host, then you want "Host only" networking. The IP address will appear if you hover over the network icon in the virtualbox window.

If you need to get to the internet from your virtualbox guest, then you can use BOTH Host only and NAT (virtaulbox supports up to 4 different network adapters).

share|improve this answer
5  
worth noting: after adding the secondary network adapter, i had to manually create another entry in /etc/network/interfaces (duplicated eth0 as eth1) and restart networking on the ubuntu guest. one of those sysadmin-type things i always forget about –  EvanK Dec 5 '10 at 23:46
    
This is important. Was pulling my hair because everywhere I read it said "use one host-only adapter and one Nat"), but without duplicating eth0 in /etc/network/interfaces as mentioned it won't work! –  stian Feb 16 '13 at 0:04
1  
@EvanK FWIW I did not need to take this step. VirtualBox setup eth0 and eth1 automatically. As your comment is old, perhaps newer versions of VirtualBox now take care of this. –  Yetanotherjosh Dec 8 '13 at 2:25
add comment

Generally from remote through nat is a pain. Depending on the virtualization technology, they each offer different methods to overcome this. Virtualbox has an option to forward port X to virtualized client if I remember properly...this would be required to do remote host access of client vm through nat.

share|improve this answer
add comment

I'm not certain about a direct answer to your question, but I access my Ubuntu box (NAT) via OS X using the following, which does us port forwarding. Replace Ubuntu with the name of your guest.:

VBoxManage setextradata Ubuntu "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 2222
VBoxManage setextradata Ubuntu "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22
VBoxManage setextradata Ubuntu "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP

Then reboot (the guest), then from OS X: ssh -p 2222 localhost And you should be in the VM in the OS X Terminal

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.