Is VirtualBox NAT networking fundamentally different than VMWare NAT?

blong picture blong · May 9, 2014 · Viewed 7.3k times · Source

I'm trying to debug a problem I'm having understanding the difference between the NAT network adapter in VirtualBox and the NAT network adapter in VMWare Fusion. So far, I can configure VMWare and achieve my desired result, but I cannot achieve this in VirtualBox. In a VMWare VM, I'm able to use a NAT network adapter to achieve the following:

  • The guest is assigned it's own unique IP address
  • The guest has access to the outside Internet
  • The host can ping the guest and ssh to it
  • The guest can ping the host and ssh to it
  • The guest can resolve (internal) domain names just like the Host

I thought I saw that this was possible in VirtualBox, but now I'm thinking it's not possible. Perhaps there is some option that is close to VMWare, in which I manually modify /etc/resolv.conf in the guest to match that of the host? I did find a few questions that seem to indicate I should instead be using Bridged mode in VirtualBox, e.g. this question: Can't ping to VirtualBox instance , in which both answers appear to suggest VirtualBox's NAT adapter doesn't support the functionality I want:

It is quite obvious that when you are using NAT it will be impossible to ping host after NAT. It is how the NAT works... even if you will have real not virtual host the bechaviour will be the same.

and

You need to change networking mode from NAT to bridged, and ping should start working in both directions.

Also, answers to this question seem to back up the above: How to ping ubuntu guest on VirtualBox

Is it true that a NAT adapter in VirtualBox cannot be ping'ed from the Host OS?

Answer

yogipriyo picture yogipriyo · May 12, 2014

I have used virtual box for years and I also have 2-3 years experience in computer networking.

Yes, in virtual box you can't ping the guest that use NAT from the host and this also how NAT works in real life. In real life, if you want to be able to contact a host behind NAT, you have to set a port forwarding rules where the connection to a certain port of the router will be forwarded to a certain machine. This must be done on the router.

To enable port forwarding in virtual box environment, select the Network pane in the virtual machine’s configuration window, expand the Advanced section, and click the Port Forwarding button. Note that this button is only active if you’re using a NAT network type – you only need to forward ports if you’re using a NAT (http://www.howtogeek.com/122641/how-to-forward-ports-to-a-virtual-machine-and-use-it-as-a-server/).