2

I'm trying to set up a lab environment with VirtualBox made up of two virtual machines, both of them Ubuntu 18.04 Bionic Beaver.

  • I want one of them to act like a server with Node.js and Express.
  • The other machine is going to act like a client, mainly sending data to the server.

Currently, they are in the same NAT network, so they can ping each other succesfully. The thing is that, if I set up an Express server in one machine, it listens, let's say, in localhost:3000. But, as expected, I can't access that address from the client machine.

I was thinking that maybe some way of port forwarding is needed, but I don't know where to start from. I understand the forwarding technique from host to guest but, even after research, I can't wonder what would be the technique from guest to guest, if that is possible.

2 Answers 2

1

If a "remote" service is attached only to the localhost adapter of the remote machine, then a SSH tunnel is a easy way to connect to it.

For your situation it would be more appropriate to bind the service to the ethernet adapter attached to your virtual lan subnet. In the "real world" if these machines were on the internet you'd then lock down the remote box to only accept connections from your other IP address(es)

1
  • 1) Do you mean to connect to the Express server through SSH? I never heard of that. 2) About your recommendation for my situation: I don't understand very well what do you mean by binding the service to the Ethernet adapter. Could you elaborate a little bit on this two things? Commented Jul 27, 2019 at 20:24
0

NAT is probably the wrong way to go here. NAT VMs can't typically communicate (at least not without special configuration in VirtualBox).

You should probably use either Host-Only adapters if you want the VMs to only communicate with each other and the host or Bridged Networking adapters if you want the VMs to be able to access anything outside the host (bridged virtual adapters are tied to your real-world network card(s)).

This official VirtualBox documentation (Section 6.2) has a handy chart of the different VM network adapter modes that you might find useful.

You must log in to answer this question.

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