Port forward in VMware Server for Linux

VMware Server is totally free. All you need is just to register your name and address to obtain a number of serial numbers. You may get up to 100 serial numbers at a time. In VMware, there are 3 network types: bridge, nat, and host-only. Bridge is the most powerful one but you need an extra IP address. If you don't have one, you might be interesting in nat or host-only. Nat seems to be better to keep your guest OS up-to-date and connected to the internet. However, Nat means you can't connect to the guest OS directly from internet so you can't run it as a server. Anyway, it is possible to forward port to the guest OS behind VMware's nat.

Usually, the nat configuration will be stored in a file named nat.conf located in each VMware's network device. For example, my host OS has vmnet8 as a nat device so there is a nat.conf as follow.

/etc/vmware/vmnet8/nat/nat.conf

Port forwarding is in section incomingtcp and incomingudp. For example, I would like to ssh to the guest OS on port 22 through port 8022 on the host OS.

[incomingtcp]
8022 = 172.16.187.3:22

After that I have to restart VMware's network services as below.

/usr/lib/vmware/net-services.sh restart

So now I can ssh to the guest OS as follow.

ssh -p 8022 myhost.com

Tags: , ,

A+

Thank you for a quick an simple How-to. I thought it's worth mentioning that you can only edit the conf file as root and vmware shouldn't be running while you restart it's services (which should also be done as root). I'm not sure if it's mandatory but it's the only way it worked for me and it makes sense: system must be clean and I must be root.

Post new comment