Search code examples
ipvirtual-machinenatgateway

Connection to a local Tomcat server through virtual interfaces


I am hoping to connect to a Tomcat server on a local host from virtual machines running on VMWare Station that connects to the host with a NAT virtual network.

I started a Tomcat server with port 8080 on my host PC.

The host normally has the following interfaces:

  1. Loopback interface, IP: 127.0.0.1

  2. An interface for the ethernet, IP: 10.10.31.194 Gateway: 10.10.31.254 The IP and DNS values are automatically assigned.

  3. A virtual interface for the virtual network VNet8, IP: 192.168.129.1 Gateway: 192.168.129.2 The IP and DNS values are automatically assigned. (This interface appears after the VMNet 8 is setup, to reduce confusion)

I can connect to a webpage (say /helloProject/helloPage.html) on the Tomcat server with the following URLs:

   http://127.0.0.1:8080/helloProject/helloPage.html

   http://10.10.31.194:8080/helloProject/helloPage.html

Then I setup my VMWare Station and opened a Network Address Translation network with the following configurations:

VMNet8

DHCP: Enabled

Subnet Address: 192.168.129.0

Subnet Mask: 255.255.255.0

Gateway IP: 192.168.129.2

But I cannot connect to the helloPage.html webpage through:

http://192.168.129.1:8080/helloProject/helloPage.html

Either from the host itself with IP 192.168.129.1, or from a Linux CentOS virtual machine with IP 192.168.129.128 on the same network.

However, pinging the host from the host or the Linux VM I get response:

ping 192.168.129.1

Reply from 192.168.129.1: bytes=32 time<1ms TTL=128

...

Can anyone suggest something to try so as to make the connection work?

In addition: VM (192.168.129.128) can reach Gateway (192.168.129.2) as well as host (192.168.129.1). But host (192.168.129.1) cannot reach Gateway (192.168.129.2), ping no response. Strange.


Solution

  • Check if you have adress=0.0.0.0 in server.xml Connector's tag for port 8080. It will tell Tomcat to listen on all interfaces available on the host. Restart Tomcat after the change.