Virtualbox NAT mode

1

I'm under the impression that I should be able to use NAT (not "NAT network" which doesn't appear to let me even hit OK) to communicate with my VM from my host.

Even after forwarding ports, I could never connect to the VM. I ran ifconfig and got the VMs IP (10.0.2.15) and no matter what ports I forwarded, I couldn't connect. I was trying to connect by typing that IP with the port in a browser.

So, I'm using Host-only mode now and it works fine (but no internet it seems).

Here's a screenshot of my settings. I would start my guest's webserver (which was running and I could curl localhost successfully on the guest) and then type in 10.0.2.15:8080 in my host's browser to no avail.

enter image description here

tau

Posted 2014-06-28T04:00:38.407

Reputation: 145

1You only need port forwarding set up if you want to allow other networked computers to access your NATed VM. Your host automatically has access to all ports on your VM. Try connecting to port 80 instead, or connect from another PC to your host's IP:8080 – Jakke – 2014-06-28T08:03:01.310

1If that doesn't work, check the local firewall on your host and make sure 8080 is allowed to accept traffic. – Jakke – 2014-06-28T08:08:22.430

it doesnt work on port 80 and i even disabled windows firewall. any other ideas? – tau – 2014-06-28T08:35:18.640

You may have to check your logs, it sounds like you have some access restriction on your VM. – Jakke – 2014-06-28T08:59:39.460

Answers

3

Virtualbox NAT mode doesn't permit the host and guest to communicate with each other without port forwarding. This is explained here.

When you tried port forwarding, it appears you set up port 8080 on the host to forward to 80 on the guest, then you tried to connect to 10.0.2.15:8080? This is incorrect. It still tries to access the guest by the guest's IP address, which isn't supported by NAT mode.

When you forward a port from the host to the guest, you need to contact the forwarded port on the host. In other words, from the host, connect to 127.0.0.1:8080 and you should be forwarded to port 80 on the guest.

Kenster

Posted 2014-06-28T04:00:38.407

Reputation: 5 474

you are exactly right. i was doing it backwards. thank you very much! – tau – 2014-06-28T17:15:24.370