I'd like to set up a Linux virtual machine using Virtualbox on OS X in the following way:

  • I'd like to use a virtual network, with my physical machine acting as a NAT to the wider internet / other networks. So, my virtual machine should have an IP address which is visible from my physical machine (I can browse to http://172.something/ and see a web server running on the virtual machine) but other machines on my physical network should NOT be able to see the virtual machine.
  • I'd like the virtual machine to be able to see "out" - it should be able to access resources on the rest of my network and on the internet as a whole.

I'm not interested in bridged networking (where the virtual machine gets an IP address on my physical network). I switch networks a lot and will be running this on a laptop, so anything that breaks if I switch from ethernet to WiFi or back again is bad.

I've tried pretty much every combination of network settings in Virtualbox and I haven't managed to get both of the above bullet points working at once - I can set up a private network behind NAT but then the virtual machine can't see the internet. I can get the virtual machine to see the internet but then I don't seem to get an IP address that my physical machine can use to access servers running on the virtual machine.

I've managed to get this setup working in both VMWare Fusion and Parallels without any trouble - any ideas how to get it working in Virtualbox?

  • I must be missing something, but if you want your host machine to be able to see the virtual machine, and your virtual machine to see the outside world - what you are describing really is working with an adapter in bridged mode (of some sort). – Goyuix Sep 10 '09 at 17:39

Please see the following question that was asked: Port forwarding to virtual machine

In a nutshell, you will want to configure your VM network adapter to be in NAT mode, then issue the following management commands:

VBoxManage setextradata VM_NAME "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort" 8888
VBoxManage setextradata VM_NAME "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort" 80
VBoxManage setextradata VM_NAME "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol" TCP
| improve this answer | |

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.