Technical

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 😀 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 10.4.0.1 on the private virtual network.
RM02 has the IP address 192.168.5.5 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 10.4.0.1:5550 instead of 192.168.5.5:5550.

Firewall Rule and netsh command
netsh interface portproxy add v4tov4 listenport=5550 listenaddress=10.4.0.1 connectport=5550 connectaddress=192.168.5.5
The network