NAT Port Forwarding in VirtualBox

I figured out the solution after much headbanging (although I figured it out some while ago, replying a bit late). The solution is to use NAT technique with port forwarding. All you have to do is, in the network setting of the vms in VirtualBox add Port Forwarding rules. There are no restriction on the value of the ports and they could be anything as long as there are no conflicting ports and it is advisable not to use certain port numbers.

For setting the rules: Host IP is the IP of your main machine and Guest IP is the NAT IP of the VM. Any request coming to your host on that port would directly be redirected to the guest ip on the port you have mentioned.

NAT port forwarding table

Here the first IP refers to my host machine, i.e. the one on which the VirtualBox is installed. And the second IP refers to the guest machine, i.e. the one which I need to start the server or connect to.


I would advise you to use Bridged mode. This will make your VM having their own IP in same network as the physical host, and behave like any physical machine on same network. Make sure both networks (from each host VM) can connect, and firewall are open on VM to communicate.