VMware Communities
macgruder
Contributor
Contributor
Jump to solution

How do I connect to my VM web server from the outside?

I'm sure there is an easy solution to this, but I've searched to no avail.

I'm running a webserver on FreeBSD in Fusion, and my Mac is using DHCP (a static address may come in due course).

My VM (fusion 2.0.1) is connected via NAT. I also use my Mac as a local server for testing but only listening on 127.0.0.1

Here's my simply question:

My FreeBSD is running Apache and is set up to serve the website ( example.com , let's say) and the DNS settings are all up to date. (I know the BSD webserver is working correctly because I can connect to it from the Safari using the Fusion IP address directly).

Now if from the outside (you, for example), type http://example.com/ into your browser it will connect to my Mac via port 80, and the Apache on my Mac will attempt to server the web page. But what I really want is the request to go onto the VM bypassing the Mac. (In Parallels, there is a setting that allows certain ports to go 'onto' the VM, but Fusion doesn't seem to have that - I'm committed to changing to Fusion because it works better with FreeBSD).

So in short:

How do I set up my VM to listen to Port 80 rather than the Mac doing so?

0 Kudos
1 Solution

Accepted Solutions
WoodyZ
Immortal
Immortal
Jump to solution

So in short: How do I set up my VM to listen to Port 80 rather than the Mac doing so?

I'm presenting this more as a proof of concept then a total step by step guide because there are many variables and you really did not include a complete topology of your LAN and other relevant information to be explicit and specific on a total scope of the project.

Okay on my MBP without Apache running in OS X and a Fusion Virtual Machine set to NAT with Apache running on the Guest I modified the nat.conf and reset the VMware Network and was then able to directly access the Guest's Web Server from another Physical Machine on my LAN.

OS X Host IP Address: 192.168.1.100

Fusion Guest NAT IP Address: 172.16.172.128

Other Physical Machine on LAN IP Address: 192.168.1.3

Named Fusion Guest: webtest

Installed Apache Server in Guest and modified the default web page to be able to be sure I'm looking at what I expect to be looking at and not the Host's Apache Server content.

Shutdown Guest and closed Fusion

Edited "/Library/Application Support/VMware Fusion/vmnet8/nat.conf" and added 80 = 172.16.172.128:80

Restarted VMware Network with: sudo "/Library/Application Support/VMware Fusion/boot.sh" --restart

Opened Fusion and started Guest

Edited Other Physical Machine on LAN hosts file to add: 192.168.1.100 webtest webtest.com www.webtest.com

Opened Browser on Other Physical Machine on LAN and typed

Now I'm looking at the Guest's Apache Server's modified default index.html.en file so this lets me know that I can access a Web Server on the NATed Guest via the Host's Port 80 from another system other then the Host.

Notes:

Obviously Firewalls need to be appropriately set to allow connectivity between the systems.

If you what the outside world to be able to access it then if your Host does not have a Static IP Address then you will need to employ some form of Dynamic DNS on the Host.

Anyway this is presented just to let you know it can be done and this is only one of may ways to go about it and without all of the relevant information I don't have the time to get into other scenarios.

Hope that helps! Smiley Happy

Message was edited by: WoodyZ

Added second - to -restart

View solution in original post

0 Kudos
8 Replies
wila
Immortal
Immortal
Jump to solution

Hi,

Welcome to the VMware forums!

Unless you install some software that does the proxying for you on the Mac side of things, you'll have to use network bridging and allow your freeBSD guest to sit on the normal network.

I don't think it can be done what you are asking for without the use of some helper software (or firewall VM)... but I'd be interested to hear it when I'm wrong.

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
0 Kudos
macgruder
Contributor
Contributor
Jump to solution

Thanks.

OK. So if I use bridged how do I set that up given that at the moment I only have a DHCP (I'm aware of the limitations of DHCP for webserving but I want to test and monitor my setup before I commit to a static IP).

0 Kudos
wila
Immortal
Immortal
Jump to solution

In order to be able to answer that question, I'll need to have a bit more information from you. DHCP is a common protocol, but it can be offered from many products.

Let's assume the most common scenario here... and suppose that you are getting a DHCP lease from your cable/ADSL modem / NAT router appliance.

In that case you would most of the times be able to create a fixed IP based on the mac address of your virtual machine.

If you are using a DHCP server from Microsoft, then there's similar options in the UI there. In those cases the fixed IP address is handed out by the DHCP server. It is also possible to set the fixed IP address by hand, but then you'll have the risk to assign an IP that clashes with another one handed out by your DHCP server. It is possible to prevent that by limiting the scope of your DHCP address pool.

From then on you can forward the http port from your WAN to the guest on your Mac.

Note that even with NAT you would not get a fixed IP and in order to route to your VM from the outside you must have a fixed IP address for your guest in one way or the other.

hth,



--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
WoodyZ
Immortal
Immortal
Jump to solution

So in short: How do I set up my VM to listen to Port 80 rather than the Mac doing so?

I'm presenting this more as a proof of concept then a total step by step guide because there are many variables and you really did not include a complete topology of your LAN and other relevant information to be explicit and specific on a total scope of the project.

Okay on my MBP without Apache running in OS X and a Fusion Virtual Machine set to NAT with Apache running on the Guest I modified the nat.conf and reset the VMware Network and was then able to directly access the Guest's Web Server from another Physical Machine on my LAN.

OS X Host IP Address: 192.168.1.100

Fusion Guest NAT IP Address: 172.16.172.128

Other Physical Machine on LAN IP Address: 192.168.1.3

Named Fusion Guest: webtest

Installed Apache Server in Guest and modified the default web page to be able to be sure I'm looking at what I expect to be looking at and not the Host's Apache Server content.

Shutdown Guest and closed Fusion

Edited "/Library/Application Support/VMware Fusion/vmnet8/nat.conf" and added 80 = 172.16.172.128:80

Restarted VMware Network with: sudo "/Library/Application Support/VMware Fusion/boot.sh" --restart

Opened Fusion and started Guest

Edited Other Physical Machine on LAN hosts file to add: 192.168.1.100 webtest webtest.com www.webtest.com

Opened Browser on Other Physical Machine on LAN and typed

Now I'm looking at the Guest's Apache Server's modified default index.html.en file so this lets me know that I can access a Web Server on the NATed Guest via the Host's Port 80 from another system other then the Host.

Notes:

Obviously Firewalls need to be appropriately set to allow connectivity between the systems.

If you what the outside world to be able to access it then if your Host does not have a Static IP Address then you will need to employ some form of Dynamic DNS on the Host.

Anyway this is presented just to let you know it can be done and this is only one of may ways to go about it and without all of the relevant information I don't have the time to get into other scenarios.

Hope that helps! Smiley Happy

Message was edited by: WoodyZ

Added second - to -restart

0 Kudos
macgruder
Contributor
Contributor
Jump to solution

Thanks WoodyZ,

Actually, I didn't know of the existence of

/Library/Application Support/VMware Fusion/vmnet8/nat.conf (one tiny error in your post "boot.sh" -restart ---> boot.sh" --restart)

This works great. At first I mistyped the ip address into the nat.conf ! But once that was sorted it worked immediately.

Many thanks.

(Edit to reflect I got it working)

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

one tiny error in your post "boot.sh" -restart ---> boot.sh" --restart

Yes it was a typo. Smiley Happy

0 Kudos
macgruder
Contributor
Contributor
Jump to solution

Hey thanks,

I'm having a similar situation with Port 25 but I can get the VM to listen in the same way. Any ideas?

Here's the thread:

http://communities.vmware.com/message/1110075#1110075

0 Kudos
macgruder
Contributor
Contributor
Jump to solution

I'm having a problem with Port Forwarding 'crashing' or stopping now. It's in this thread:

http://communities.vmware.com/thread/182558

I'd be grateful if you could take a look. Thanks!

0 Kudos