7

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?

3 Answers 3

15

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).

3
  • 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
    Commented Dec 5, 2010 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
    Commented Feb 16, 2013 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. Commented Dec 8, 2013 at 2:25
1

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.

1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .