I have a LAN with 2 PC, one of the PC is a vmware workstation host. I installed a virtual machine behind NAT. (I do not want Bridge.) I set the port forwarding (22 SSH) in the vmware virtual network editor. I can ssh into the virtual machine from the host, but can not from the another machine. (openssh is installed). My guess is the PC does not know the route. How to solve this problem?

  • 1
    Add a route? The method depends on the OS... – acejavelin May 2 '18 at 11:45
  • I am not good at adding route. Where to add it. In the PC or in the router. I can SSH between the 2 PC both are Ubuntu. Based on the the trace route I should add in the router, because it leaves the LAN network after the LAN gateway. Can you explain it why? – István Radics May 2 '18 at 11:59
  • The host and VM share the same visibile IP address... If the host has a service on port 22, the guest cannot use it as well. You need to do splir port forwarding, maybe 8022 on visible side and 22 on private side, or change the port you are using for ssh entirely on the guest. – acejavelin May 2 '18 at 12:19
  • I managed to change the ssh port on the virtual machine and I could connect from the host successfully, but still no luck with the other PC. I put in the routing table of the router a new route dest: mask GW:vm_host_pc. The traceroute stopped at the GW and nothing... – István Radics May 2 '18 at 13:03

Last advice: I imitated your setup in both VirtualBox & VMware Workstation and I can connect to VM from PC1( & PC2( using, NAT port forwarding host port 8022 guest port 22, VM IP in VBox, VMware No route was added.


First check that your firewall is not blocking the port. Next set up port forwarding in your router. I see in your comment above that you've put as the gwateway - that wont work. Put the gateway to something like, if the other pc is in the same subne. It will work if machine 1 has eg. IP and machine 2, but not if machine 2 has IP - than you'd need to set a subent mask of

  • Hi and93hil. I have a simple home network with 2 pc and a router. PC1 PC2 And PC2 has a virtual machine behind NAT. VPC I used the because I gave a the specific dest VIP. I still not understand this subnet thing, but I would like to force the PC1 to search the VPC under the PC2. According the the traceroute from PC1 toward VPC it search the VPC outside the LAN. – István Radics May 2 '18 at 13:29
  • either give your virtual PC a IP adress 192.168.137.xxx or set the subnet to – and93hil May 2 '18 at 15:53
  • Can you explain , why will see the other net, if I set the mask for. The number of host will increase, so will see the router every IP after 192.168.x.x, but what if if I have more network? – István Radics May 3 '18 at 12:13
  • that's how subnet masks work. alternative is that you create a route to the other net with your router /switch. – and93hil May 9 '18 at 14:52
  • Finally I managed to reach the VM behind NAT. I used the port forwarding solution. Still a bit strange to use the VM host IP to reach the VM guest. This link was useful: ask.xmodulo.com/access-nat-guest-from-host-virtualbox.html – István Radics May 15 '18 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.