# Tcp port redirections with redir

**URL:** <https://linux-tips.com/t/tcp-port-redirections-with-redir/199>\
**Category:** Network\
**Created:** [July 31, 2008, 12:49pm UTC](https://linux-tips.com/t/tcp-port-redirections-with-redir/199 "2008-07-31T12:49:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![demirezen](https://linux-tips.com/letter_avatar_proxy/v4/letter/d/54ee81/32.png) [@demirezen](https://linux-tips.com/u/demirezen)\
**Post date:** [July 31, 2008, 12:49pm UTC](https://linux-tips.com/t/tcp-port-redirections-with-redir/199/1 "2008-07-31T12:49:58Z")

</div>

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
```
