Using Redir command for redirecting ports

Redir is a very useful command line script that allows port redirection. The script listens on the given TCP port and forwards incoming connection to the given IP address and port.

One use case for the Redir command is to setup SSH access for a container that is running inside a host system. For example if you are running LXC containers on a server and you want to be able to SSH to a container from outside the server, then you can use the redir command to redirect incoming connections on SSH port 22 or some other port to the SSH port of your container.

The following redir command listens on all available IP addresses and port 1000. It redirects all incoming connections to port 22 on host The ’&’ at the end of the command allows the command to run in the background.

redir --laddr=  --lport=1000 --caddr= --cport=22 &
Published 22 Nov 2017

Pak Jiddat provides open source scripts and tutorials related to Web Development and System Administration.