ben robison
when only more words will do
Howto: Port forward to Your Virtual Machine
So sometimes I do things just for the fun factor. As mentioned in a previous post, I like having Windows server, but I prefer Linux for web-hosting. I finally found the solution to do both at the same time on one machine. In the real world people have been doing this for years, but it’s a first for me.
After doing all my installing, I then installed VMWare’s now free VMWare Server. I downloaded the Ubuntu Server distro and decided on the 6.10 release dubbed Edgy Eft. It doesn’t have the LTS, but is perfect for my needs because the repositories include everything I need for my Ruby on Rails setup (including Lighttpd).
Then I just had to figure out how to get traffic from my host to my virtual host. I wanted to use Bridged Ethernet and did that originally, but even though my VM grabbed an IP address on my Lan, when trying to access it from another computer, I was told that there was:
No route to host
If you’re smarter than I am, you can probably figure out a way around this, but I was just trying to get it to work. I turned to NAT. Go to VM > Settings > Ethernet in your VMWare Server Console, select NAT, and click OK.
Now boot your VM log in, and run an
ifconfig
to see what your IP Address is. Again in your server console go to Host > Virtual Network Settings. Select the NAT tab. Make sure to move this window so you can clearly read your VM’s IP address. VMNet8 is the default virtual adapter for NAT, so if this is your only VM go ahead and click the Edit button (if you have others, make sure to select the proper adapter for your VM from the dropdown menu, then click edit). Now click the Port Forwarding button and then the Add button. Fill in the host port, the VM ip address, and the VM port. For me this meant forwarding port 80 from the host to port 80 on the VM. Don’t forget a nice description. Click OK 4 times. Now just forward traffic through your router (as needed) and you’re good to go.
My Ubuntu VM is now serving Apache2+MySql+PHP5 to the world. Soon it will be serving Ruby on Rails.
For a graphical tutorial see:
Subscribe to RSS
[...] if you need to forward traffic to your VM, then at your router point port 22 at the host OS and follow my other instructions on port forwarding to a virtual [...]
Okay, so I’ve got a host on a lan, and a VM to be used as an e-mail server. Should the router point ports 110 and 25 to the host machine’s static IP address, vmnet8’s IP address, or what?
That depends on how your VM is setup. If it’s using bridged Ethernet, then it should be grabbing it’s IP address from your router anyway. If this is the case, then you should be able to forward traffic directly from the router to the VM. Check your IP address on your virtual machine. If it’s in the same range as your host machine (probably 192.168.x.x) then you’re probably using bridged ethernet. If this is the case, then you should be able to forward from the router directly to the VM.
As I mentioned above, this didn’t work for me, so I used NAT instead of the bridged ethernet. If you’re going with this route, then you need to point those ports form your router to your host machine, then go into the VM settings as described and forward those ports again so that they can get to your virtual machine.
With all the Parallels/Fusion/Mac’s running Windows VMs, this is even more applicable now than it was a year ago when I wrote this.
I cannot access my Linux which is inside my VM ware from outside my Host system. I possible do send in your comments to rojan555@gmail.com
Thank you, this helped dearly!