Lewati ke isi

TCP port redirector

This is a TCP port redirector for UNIX. It can be run under inetd or as a standalone daemon (in which case it handles multiple connections). It is 8-bit clean, not limited to line mode, yet small and lightweight. If you want access control, run it under xinetd or inetd with TCP wrappers.

redir listens for TCP connections on a given SRC:PORT. When clients connect to redir it initiates a connection to the server on DST:PORT to pass data between them. The SRC and DST are from the perspective of redir.

                      -------> SRC:PORT -----> DST:PORT

Request:       CLIENT -------> redir --------> SERVER


Response:      CLIENT <------- redir <-------- SERVER
                                     --bind=addr

Note: the --bind=ADDR argument is to limit redir on the server side reply, in case the box redir runs on have multiple addresses or interfaces on the server side.

install

sudo apt install redir

Examples

To redirect port 80 to a webserver listening on loopback port 8080, remember to use sudo when using priviliged ports:

sudo redir :80 127.0.0.1:8080

This starts redir as a standard UNIX daemon in the background, with all log messages sent to the syslog. Use -n to foreground and see log messages on stderr.