Socat and port forwarding

2019-03-25

I have found a way to forward requests from one machine's specific port to another machine's specific port. There is a package called socat for this.

A short example:

socat -v tcp4-listen:port1,reuseaddr,fork tcp4:address:port2

In this case:

  • port1 - the port the local machine is listening on
  • address - the IP address of the machine the traffic is forwarded to
  • port2 - the port the remote machine is listening on