Installing socat
centos
yum install -y socat
ubuntu or debian
apt-get update
apt-get install -y socat
Using socat
1. Forward TCP
Description:
TCP4-LISTEN:10000 listens on IPv4 TCP port 30000. Change 30000 to the port you want to forward
fork TCP4:1.1.1.1:30000 forwards to port 30000 on 1.1.1.1. Modify the IP and port as needed
nohup runs in the background. You can put this command into /etc/rc.local to start it automatically on boot.
nohup socat TCP4-LISTEN:30000,reuseaddr,fork TCP4:1.1.1.1:30000 >> socat.log 2>&1 &
2. Forward UDP
nohup socat -T 600 UDP4-LISTEN:30000,reuseaddr,fork UDP4:1.1.1.1:30000 >> socat.log 2>&1&
Enter the two commands to enable TCP+UDP forwarding