How can I connect to a web server running in a VM when the VM is in NAT mode?

23

11

I've got a development webserver on an Ubuntu box inside of VMWare Workstation 7.1.3. I'd like to run a web browser on a Windows machine (the host OS) for actually testing a web page I'm working on -- hard to run IE tests in Ubuntu :)

However, if I simply try to ping the IP given to the ubuntu VM (192.168.83.137) (or open it in my browser for that matter), it seems the host cannot communicate with the guest.

How do I allow the guest OS to communicate with the host when the guest is running in NAT mode?

Billy ONeal

Posted 2011-02-13T00:18:32.687

Reputation: 7 021

I dont have the VMWare in this computer so I cannot try now, but I did this. What I recall was, there is an IP for NAT and one for Direct connection. If I'm not mistaken, I just opened the NAT address in my browser – Alex Angelico – 2011-02-14T01:48:34.130

@Alejandro: That's what I thought too but it doesn't seem like the Ubuntu box is accessable that way. – Billy ONeal – 2011-02-14T02:41:53.467

Answers

18

I have this configuration working in my computer:

host: Windows 7

VMWare: openSUSE 11.x using NAT

If i run ifconfig on linux, I have this ip: 192.168.126.129. In the host I have adpater VMNet8: 192.168.126.1

I opened in the browser the URL: http://192.168.126.129/ and it opened the apache "IT Works" page

If this doesnt work, check the firewalls an/or if apache is listening at 192.168.126.xxx.

Alex Angelico

Posted 2011-02-13T00:18:32.687

Reputation: 647

1Well, I'm guessing firewalls were choking things up. Not an issue anymore. – Billy ONeal – 2011-03-05T02:30:30.917

5

You will need to setup port forwarding to the guest machine.

On the NAT tab in Virtual Network Editor, click Edit -> Port Forwarding. From here you can configure which ports are forwarded from the host machine to the VM.

For example, forwarding host port 8080 to the VM 192.168.83.137:80 should allow you to access the web server on the VM by going to http://127.0.0.1:8080 on the host machine.

For further information, refer to the VMWare Nat Documentation or the following article

lstg

Posted 2011-02-13T00:18:32.687

Reputation: 71