Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
I have CentOS installed in VMware workstation 7, and it is currently using the default NAT/bridging virtual network setup (I didn't know what any of this stuff meant, so I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2010
    Posts
    7

    Port forward to VMware NAT -> VM


    I have CentOS installed in VMware workstation 7, and it is currently using the default NAT/bridging virtual network setup (I didn't know what any of this stuff meant, so I chose to leave it alone during install).

    In the host computer (that is, the computer that is running VMware), I can see what appear to be 2 local IP addresses that belong to the VMware virtual network. these addresses are 192.168.126.1, and 192.168.162.1. in the host machine's Control Panel (Windows), I can see my physical NIC card along with what appear to be 2 virtual cards, "VMware Network Adapter - VMnet1", and "VMware Network Adapter - VMnet8". after checking each card's IPv4 properties, I can see that:

    VMnet1 = 192.168.216.1
    VMnet8 = 192.168.162.1

    in CentOS running in the VM, this is the output of an "ifconfig":

    eth0 Link encap:Ethernet HWaddr 00:0C:29:F4:29:8D
    inet addr:192.168.162.128 Bcast:192.168.162.255 Mask:255.255.255.0
    inet6 addr: fe80::20c:29ff:fef4:298d/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:178 errors:0 dropped:0 overruns:0 frame:0
    TX packets:210 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:36653 (35.7 KiB) TX bytes:19184 (18.7 KiB)
    Interrupt:67 Base address:0x2000

    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    inet6 addr: ::1/128 Scope:Host
    UP LOOPBACK RUNNING MTU:16436 Metric:1
    RX packets:3183 errors:0 dropped:0 overruns:0 frame:0
    TX packets:3183 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:4564008 (4.3 MiB) TX bytes:4564008 (4.3 MiB)
    I have lighttpd installed in CentOS, and would like to be able to connect to it from within my local network (e.g.: from this host computer running Windows). if possible, I would also like to be able to connect to this from anywhere on the internet. although my IP is assigned dynamically from my ISP through DHCP, I hope to resolve this by enabling a DynDNS updating feature that is built in to my modem/router (instead of connecting to fixed IPs that aren't static, I'll connect to my DynDNS hostname and let DNS find them).

    basically the idea is to replicate a fully functional HTTP server that is accessible both locally and remotely, without the need for any actually dedicated hardware. I would like to eventually rent a dedicated server or get one colocated at a datacenter, but I would first like to brush up on my linux skills and get my homepage complete or at least well tested before officially opening it to the public.

    some might discount my VMware idea, however I think it is a good way to get acquainted with linux without making any big and possibly costly decisions. it's also an easy way to restart from scratch if I seriously mess something up with my beginner linux experiences. I learned not long ago that mistakes in linux are not as forgiving as they are in Windows - I tried changing the root shell to bash, and installed bash with a newer dependancy library than it had expected - permanently locking myself out of the root shell. I did create a normal user account before this happened, but unfortunately I had also changed the shell to bash in that account, so it was the same deal ("unable to start bash", or something like that). say for example that had happened to a remotely hosted server, I would have had to ask the datacenter to reinstall CentOS for me, which could have resulted in loads of lost customer data and hours of downtime, not to mention embarassment.

    the problem I am having is deciphering the VMware virtual NAT from my physical NAT, and establishing a connection between the 2. this is the path of forwarding I would like:

    {INTERNET} - NAT (physical) -> NAT (virtual) -> VM (CentOS)

    could someone please tell me how I could go about getting this working? it's probably pretty simple, but I've tried countless times without any luck.

    any help would help alot, I've been googling and trying bits of guides that seem somewhat relevant, but still no luck. I can't even manage to connect to lighttpd locally from the loopback in CentOS, so I don't know what is happening.

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,752
    VMware Documentation


    Workstation User's Manual - Page 318/319

    Network connections that are initiated from outside the NAT network to a virtual
    machine on the NAT network are not transparent. When a machine on the external
    network attempts to initiate a connection with a virtual machine on the NAT network,
    it cannot reach the virtual machine because the NAT device does not forward the
    request.
    However, you can configure port forwarding manually on the NAT device so that
    network traffic destined for a certain port can still be forwarded automatically to a
    virtual machine on the NAT network. See “Advanced NAT Configuration” on page 319.
    Same as Workstation 5.5


    Google: vmware nat port forwarding windows

    * Port forwarding from "the internet" into your home network is done on your router. The router would need to forward the correct port (80?) from the router to the VMware host machine. The VMware machine will then forward it onto the virtual NAT if it's been configured to do so.
    Last edited by HROAdmin26; 03-17-2010 at 07:22 AM.

  3. #3
    Just Joined! DT0X's Avatar
    Join Date
    Nov 2008
    Location
    Southwest UK
    Posts
    31
    You could also set the VM to have a bridged connection to your router and get a LAN IP (DHCP) as opposed to an internal virtual IP then it would be accessible from your LAN as if it was an individual box and routing should be transparent from inside your LAN.

    But then to get access from the internet to it you would still have to set up the port forwarding on your router as HROAdmin26 stated above.

    From http://www.vmware.com/products/workstation/faqs.html:
    Does a VMware Workstation virtual machine share the IP address of the host (NAT), or does it have its own IP address?

    The virtual machine can use bridged networking to receive its own IP address (when available from a DHCP server), or it can use NAT and share the host's IP address. Also, host-only networking can be set to create an isolated virtual network. Lastly, network connections can be entirely disabled for complete virtual machine isolation.

    As for not being able to access lighttpd on localhost:

    Is lighttpd running (service lighttpd start)?
    Are you browsing to localhost ?
    Do you get any errors in /var/log/lighttpd* ?

  4. #4
    Just Joined!
    Join Date
    Mar 2010
    Posts
    7
    So first I need to forward TCP port 80 at my router. which IP should I be forwarding this port to?

    secondly I need to forward the same port at the virtual NAT? which IP should I be forwarding the port to?

    thirdly, lighttpd is running, it appears in the list of services that are started when I start CentOS. I am browsing to the localhost loopback IP on the HTTP protocol ("hxxp://127.0.0.1/"). note that when I attempt to connect to this IP: 192.168.126.1, I get a "connection terminated" error (it states that although the address appears valid, the connection was terminated before the page could load). there are no errors in the error.log file in /var/log/lighttpd*, only messages stating when the service has been started and stopped (I assume on CentOS startup and shutdown).

    I have searched google far and wide for this and found the same links on the VMware site and community, which appear to be helpful, although they are just telling you how to access the Virtual Network Editor to edit NAT settings, etc. they have a little bit of info on port forwarding manually, however it involves editing fields in /etc/vmware/vmnet8/nat/nat.conf, which is clearly for running VMware in Linux (I am running Linux on VMware, VMware in Windows).

  5. #5
    Just Joined! DT0X's Avatar
    Join Date
    Nov 2008
    Location
    Southwest UK
    Posts
    31
    secondly I need to forward the same port at the virtual NAT? which IP should I be forwarding the port to?
    I would enable / configure bridging on VMWare instead of the NAT that you already have.

    So first I need to forward TCP port 80 at my router. which IP should I be forwarding this port to?
    Then you forward port 80 on your router to the DHCP bridged address your CentOS box would get once bridging is enabled (this is the way I also do it using VMWare and CentOS but for SSh instead of http)

    What does the access log for lighttpd say when you browse to localhost? Do you have any iptables rules or other security settings?

  6. #6
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,752
    Quote Originally Posted by procrastine View Post
    So first I need to forward TCP port 80 at my router. which IP should I be forwarding this port to?
    Code:
    The router would need to forward the correct port (80?) from the router to the VMware host machine.
    secondly I need to forward the same port at the virtual NAT? which IP should I be forwarding the port to?
    Code:
    However, you can configure port forwarding manually on the NAT device so that
    network traffic destined for a certain port can still be forwarded automatically to a
    virtual machine on the NAT network.
    The CentOS VM.

    thirdly, lighttpd is running...
    Browsing from WHERE? Only the VMware Host or the CentOS VM will likely be able to access the webserver. If you can get to the webserver's IP and still can't access the webpage, then it's likely a lighthttp config issue - check the lighthttp docs.
    they have a little bit of info on port forwarding manually, however it involves editing fields in /etc/vmware/vmnet8/nat/nat.conf
    What? The docs state clearly how to access the NAT network IN THE WINDOWS GUI and the Workstation 5.5 link I posted has a SCREENSHOT of the GUI with a button that says "Port Forwarding."

    I'm done - good luck.

  7. #7
    Just Joined!
    Join Date
    Mar 2010
    Posts
    7
    I do have APF installed, but in the CentOS System -> Administration -> Security Level and Firewall, I do have "WWW (HTTP)" enabled as a trusted service. where is the lighttpd access log stored (google turned up: /var/log/lighttpd.access.log, but its not there).

    DT0X: in the Virtual Network Editor it seems a feature called "Auto-Bridging" is enabled. I wouldn't have the slightest clue how to change this from the current NAT setup, as I said this is the default setup, I chose to leave it alone. I wish I had of chosen this in the first place, because it probably wouldn't have been confusing as this virtual NAT setup is making things.

    HROAdmin26: So you are saying that I should forward the port from my router to this Windows machine that is running VMware? I apologize that I did not earlier understand what you meant by "VMware host machine", I thought you meant the actual CentOS VM. I didn't think the Windows machine had anything to do with the virtual NAT, but I guess it is getting the connection through it so it probably does.

    I still do not know which one of these addresses belongs to the CentOS VM, although I believe it is either 192.168.126.1 or 192.168.162.128.

    Yes I am aware that the links you posted have details on how to access the virtual NAT network and port forwarding via the Virtual Network Editor, but that is what I meant by the links simply telling you how to access these functions (I never said I didn't know how to access the port forwarding feature on the virtual NAT). they just tell you how to open the Virtual Network Editor and the port forwarding window through NAT settings, they don't step you through the actual forwarding process, which is what I'm having trouble with, not accessing the forwarding window.

    And yes I am browsing to 127.0.0.1 from inside the CentOS VM, that is what I meant by "local loopback" (this terminology appears in the ifconfig made on the CentOS VM). I realize that browsing to localhost on the VMware host machine (Windows) will not get me anywhere, because there is not even an HTTP server installed on this machine. the original question asked if I was browsing to localhost, not where I was browsing from, so there is no need to get hostile (I thought I was asked what address I was using when I was attempting to browse to localhost, which explains why I answered 127.0.0.1).

  8. #8
    Just Joined! DT0X's Avatar
    Join Date
    Nov 2008
    Location
    Southwest UK
    Posts
    31
    Im not being hostile - just trying to get to the bottom of it through deduction.

    What HROAdmin26 is saying is that yes using your current setup you should forward from your router to your windows host machine on port 80 then use the internal forwarding on VMWare to go from your host adapter to 192.168.162.128 which is your CentOS internal IP (from output of ifconfig in original post)

    But like I said this just isnt how I would do it - bridging is so much better for situations like this as the box will act like its an independent server on your home network, if it was me I would start again.

    Not sure about your lighttpd issue, sounds like you have problems there too - if theres been no access to the server then the access log wont have been created so thats probs why its not there. Is apache installed? Maybe try firing it up and see if you can get a basic page with that instead? Might be a lighttpd config / installation issue.

  9. #9
    Just Joined!
    Join Date
    Mar 2010
    Posts
    7
    thanks DT0X, I've got Apache working with the virtual NAT setup, I don't know what the problem was with lighttpd but its been uninstalled.

    you're saying that I could set bridging directly to my modem router, and let the CentOS get its own IP via DHCP. as far as I know, my modem/router consolidates all
    connections under a single IP (all machines connected to this LAN share the same WAN IP).

    the problem with such a setup I would think would be finding the IP that the CentOS machine is getting via DHCP, if my ISP would even allow me to obtain a second WAN IP (I don't pay for any extra IPs or anything). would it be possible to install some sort of dynamic updating client in CentOS that would update my DynDNS hostname every time the CentOS VM obtains a new IP? is this the way that you do it?

    I see what you mean by the VM operating independent of the LAN in this setup, and really it would be more similar to the remotely hosted server setup which I am trying to replicate.

  10. #10
    Just Joined! DT0X's Avatar
    Join Date
    Nov 2008
    Location
    Southwest UK
    Posts
    31
    Depends what type of router you have - if its like a Netgear or a Draytek or a ISP supplied modem/router then it should act as an internal DHCP server for any devices you plug into it (does it have spare ethernet ports).

    Then you just forward through it directly to the IP your CentOS box picks up (once youve enabled bridging in VMWare) - you can find out what that IP is with the ifconfig -a command you used originally (or just type "ip a")

    All you need the dynDNS for is when your WAN IP changes, not your internal DHCP address - and yes you can install the client on your CentOS box or your windows box and it will update dynDNS for you.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •