Can't ping to VM on another computer, even with route table entry

0

I have 2 computers. Computer A is running a VM, which is behind a NAT. Computer B just wants to PING that VM. I know that VM behind NAT is intended to be inaccessible from the outside, that's why NAT is there in the first place. My experiment is just to learn how this all works.

IP of computer A: 192.168.1.105

IP of the VM on computer A: 172.16.66.132

IP of computer B: 192.168.1.107

From my understanding, computer B cannot PING the VM, because it does not know how to get there and it's trying to get there via the router (192.168.1.1), which fails, because router then goes to Internet (which I verified with tracert).

I thought I could change that by adding a custom entry to routing table on computer B. So, I did that:

route add 172.16.66.0 MASK 255.255.255.0 192.168.1.105

The rule above would inform computer B that network 172.16.66.0 is accessible via 192.168.1.105 (which is the IP of computer A).

Result? No change. I even saw that, while PINGing the VM, my custom entry has been removed from the table.

Why doesn't my solution work?

Loreno

Posted 2019-08-24T17:21:38.997

Reputation: 115

Answers

1

The route add command is ineffective and the route is probably removed because it was tested and came up as invalid.

The reason is that you have a situation of double-NAT : The virtual machine software you are using has its own virtual router that does DHCP and NAT for the virtual machines. The host computer has no route to that virtual router, so is unable to forward anything.

I suggest defining for this case the virtual network as Bridged instead of NAT.

harrymc

Posted 2019-08-24T17:21:38.997

Reputation: 306 093

Well, I'm doing that just as an experiment, to learn something. I was curious if there is any option to access the VM with the current setting. – Loreno – 2019-08-25T11:59:59.157

I don't know of any way of referring to the virtual router, and this is probably by design. – harrymc – 2019-08-25T12:01:53.260

If my answer has helped with the problem, please accept it. – harrymc – 2019-08-25T12:02:08.410