There is a built-in ability in Microsoft Windows to set up network ports forwarding. Due to it, any incoming TCP connection (IPv4 or IPv6) to local port can be redirected to another local port or even to port on the remote computer. And it is not necessary for system to have a service that listens to this port.
Port forwarding in Windows can be configured using Portproxy mode of the command Netsh. The syntax of this command is as follows:
netsh interface portproxy add v4tov4 listenaddress=localaddress listenport=localport connectaddress=destaddress connectport=destport |
where
Let’s imagine that our task is to make the RDP service to respond on a non-standard port, for example 3340 (the port can be changed in the settings of the service, but we will use RDP to make it easier to demonstrate forwarding). To do this, you need to redirect incoming traffic from TCP port 3340 to another local port – 3389 (standard rdp port).
netsh int portproxy add v4tov4 listenport=3340 listenaddress=10.1.1.110 connectport=3389 connectaddress=10.1.1.110 |
Below example enables your PC to forward all packets from any clients on 15000 to 10.65.8.239
netsh int portproxy add v4tov4 listenport=15000 listenaddress=0.0.0.0 connectport=15000 connectaddress=10.65.8.239 |
Once you run "netsh", server will permanently remember the configuration as long as you do not delete it. |
netsh int portproxy show all |
You will be able to see the list like below
netsh int portproxy reset all |
Other reference associated with NetSh