Redirects TCP connections from one IP address and port to another.
I have used this tool for many years. It redirects the TCP traffic received on a local address/port to a port of a remote machine.
It is very useful in complex network architectures, where firewalls allow connections only from one specific machine to another: you can run SockRedirector on the trusted machine and reach the remote server through it.
The concept is very similar to a proxy, without being limited to HTTP connections and without the need to implement a SOCKS interface.
SockRedirector is written in Java and runs on Linux, Windows, macOS, AIX, AS/400 or any environment with a Java runtime. Native executables (built with GraalVM) are also available for Linux, macOS and Windows.
- Java 11 or later to run the jar
- To build: JDK 25 and Maven (GraalVM 25 to build the native executable)
# Runnable jar: target/SockRedirector-<version>-jar-with-dependencies.jar
mvn package
# Native executable (requires GraalVM): target/Sockredirector
mvn package -DskipNativeVersion=falsePut a sockRedirector.ini file in the working directory and start the program:
java -jar SockRedirector-<version>-jar-with-dependencies.jarLogs are written to the console and to logs/sockRedirector.log.
The ini file is divided into one or more <redirection> sections. For each section you can define these parameters
| key | type | default | value |
|---|---|---|---|
| source | string | mandatory | source ip to bind, listen on |
| sourceport | int | mandatory | source port to bind, listen on |
| destination | string | mandatory | destination host |
| destinationport | int | mandatory | destination port |
| log | boolean | false | dump the traffic of each connection under logs/ |
| timeout | int | 0 | source socket timeout (seconds), 0 = no timeout |
| client | int | 10 | max pending connections on the source (backlog) |
| blocksize | int | 64000 | size of buffer to read from source and destination |
| inReadWait | long | 0 | pause before reading from destination (ms) |
| inWriteWait | long | 0 | pause before writing to source (ms) |
| outReadWait | long | 0 | pause before reading from source (ms) |
| outWriteWait | long | 0 | pause before writing to destination (ms) |
| randomKill | long | 0 | testing only: randomly close connections (about once every N seconds), 0 = disabled |
<redirection>
<source>127.0.0.1</source>
<sourceport>80</sourceport>
<destination>1.1.1.1</destination>
<destinationport>80</destinationport>
<log>true</log>
<timeout>0</timeout>
<client>50</client>
<inReadWait>0</inReadWait>
<inWriteWait>0</inWriteWait>
<outReadWait>0</outReadWait>
<outWriteWait>1000</outWriteWait>
</redirection>While running, SockRedirector accepts these commands on standard input:
| command | description |
|---|---|
| help | show the command list |
| exit | exit program |
| thread [filter] | list active connections |
| kill <id> [<id> ...] | close the given threads |
| pause <id> <readPause> <writePause> | set read/write pause (ms) on a flow thread |
For the full SockRedirector documentation, visit Deep Wiki.