Tcp port redirections with redir

Redir is a port redirector.

It’s functionally basically consists of the ability to listen for TCP connections on a given port, and when it recieves a connection, to then connect to a given destination address/port, and pass data between them.

To redirect TCP connections with redir utility, simply type the command such as below:

redir --laddr=<listen_address> --lport=<listen_port>  \
      --caddr=<connect_address>  --cport=<connect_port>

Suppose that the ip address of our system is 1.1.1.1 and we would like to redirect all the traffic which coming from port 80 to a remote server with ip address of 2.2.2.2 and port 8080. Simply, we want redir utility to redirect connections coming to 1.1.1.1 on port 80 to 2.2.2.2 port 8080. We have to run redir such as below to do so:

redir --laddr=1.1.1.1 --lport=80  --caddr=2.2.2.2 --cport=8080

Local address specified with --laddr should be one of the ip addresses that we can access our redirecting system. Setting other ip addresses will make no sense.

redir also has a transparent proxy feature. You can use iptables for this type of redirection too but if you can’t use iptables for any reason, it is possible to use transproxy support any port you want like that:

redir --transproxy 1.1.1.1 80 3120