windows 自带的端口转发程序

Since Windows XP 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

listenaddress – is a local IP address waiting for a connection.
listenport – local listening TCP port (the connection is waited on it).
connectaddress – is a local or remote IP address (or DNS name) to which the incoming connection will be redirected.
connectport – is a TCP port to which the connection from listenport is forwarded to.

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).

Start the command prompt as an administrator and perform the following command:

netsh interface portproxy add v4tov4 listenport=3340 listenaddress=10.1.1.110 connectport=3389 connectaddress=10.1.1.110

windows port forwarding rule using netsh interface portproxy add

Where 10.10.1.110 – the current IP address of this computer.

Using netstat make sure that port 3340 is listened now:

netstat -ano | findstr :3340

netstat -ano - Get process PID

你可能感兴趣的:(windows 自带的端口转发程序)