Netsh implements port mapping (port forwarding) under windows

After searching on the Internet, I found that the windows system, including xp 2003, 2008, etc., the netsh tool has its own portproxy function. Currently, only port forwarding of tcp protocol is supported. The premise is that IPV6 needs to be installed as the host of portproxy. IPV6 can not be enabled during installation.

The following commands need to be run with administrator privileges, so when starting cmd, start as administrator

A. Configuration method
Assuming that you need to connect port 1494 of 192.168.1.118 through port 14941 of 192.168.1.8, you need to enter the following statement on the command line of the 192.168.1.8 host
--- If IPV6 has been installed, this statement does not require
netsh interface ipv6 install
--- It is not necessary to specify the local listening address, which can be achieved by providing a floating address by the operating system. If the operating system has opened the host firewall, the inbound connection of TCP 14941 needs to be released

netsh interface portproxy add v4tov4 listenaddress=192.168.1.8 listenport=14941 connectaddress=192.168.1.118 connectport=1494

or

netsh interface portproxy add v4tov4  listenport=14941 connectaddress=192.168.1.118  connectport=1494

--- Cancel the port forwarding configured above, you can use the following statement:

netsh interface portproxy delete v4tov4 listenaddress=192.168.1.8 listenport=33891
--- If you want to see which port forwarding has been configured, you can use the following statement:

netsh interface portproxy show  v4tov4

B. Advantages
You can add or delete port forwarding entries at any time as needed, and restarting the operating system can still automatically save the previous configuration and enable it automatically, unlike HAproxy, which needs to restart HAproxy after modifying the configuration file.
Some people on the Internet say that xp configuration port forwarding does not work. It is estimated that IPV6 is not installed. Using xp to test, port forwarding can be achieved after IPV6 is installed, and there is no need to enable routing and remote access services. In addition, considering the redundancy of port forwarding, you can configure port forwarding on multiple hosts.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325960377&siteId=291194637