Port Forwarding with netsh

If I don’t note this down I *will* forget how to do it.

Ever used netsh? That powerful but largely ignored command line tool in Windows? Turns out it can do port forwarding too :D only TCP but still rather helpful.
Say you’re building a virtual network of Windows servers and you want them to be in their own isolated clump, yet still be able to access a particular port on a real server, on the real network. It’s weirdly easy to do.

VM01 and VM02 are virtual servers in a private network, VM01 has a second network interface with access to the real world. RM01 and RM02 are on the same real network. RM01 hosts the two VMs, and RM02 runs a service on TCP port 5550.

VM01 has the IP address on the private virtual network.
RM02 has the IP address on the real network.
VM01 can see RM02.

Allow incoming connections to VM01 on TCP port 5550 through the firewall.
Use netsh to forward all traffic on that port to RM02.
Tell VM02 to use instead of

Firewall Rule and netsh command

The network

Leave a Reply