Win&linux port forwarding use

Application scenarios:

        pc1<---------------->pc2
     211.20.3.1           172.36.56.2

pc1 can communicate with the external network, pc2 can communicate with the internal network, but cannot communicate with the external network, but pc1 and pc2 can communicate with each other;
requirement: access pc2 through pc1

pc1 is windows

1. Open cmd with administrator authority;
2. Add port forwarding;
netsh interface portproxy add v4tov4 listenport=10022 connectaddress=172.36.56.2 connectport=22
listenport is the local listening port;
listenaddress is the local listening address, if not configured, it means all;
connectaddress is the remote ip address to be connected;
connectport is the port of the remote device to be connected ;
3. Delete port forwarding
netsh interface portproxy del v4tov4 listenport=10022

pc1 for linux

Take ubuntu as an example:
use the tool ncat to implement port forwarding.
1. Install ncat
apt-get install ncat
2. Enable port forwarding
ncat --sh-exec "ncat 172.36.56.2 22" -l 10022 --keep-open
-l is the listening local port;
3. Other methods
iptables, portmap, portfwd, etc.

Guess you like

Origin blog.csdn.net/sun172270102/article/details/115319175