socat 端口转发

简介:socat是一种TCP或UDP流量转发工具。支持单端口转发,但不支付端口段转发。要想端口段转发请参考  iptables 端口转发

部署:

ubuntu/debian 系统: apt-get update -y && apt-get install socat -y
centos 系统: yum update -y && yum install socat -y

配置:

1、将本机(本机指的是你正在操作的机子)12345端口上的数据转发到2.2.2.2的12345端口。(两个端口可以不一样)

nohup socat TCP4-LISTEN:12345,reuseaddr,fork TCP4:2.2.2.2:12345 >> /dev/null 2>&1 &
nohup socat UDP4-LISTEN:12345,reuseaddr,fork UDP4:2.2.2.2:12345 >> /dev/null 2>&1 &

2、将本机(本机指的是你正在操作的机子)ipv6的12345端口上的数据转发到远程机ipv6的12345端口。(两个端口可以不一样)

nohup socat TCP6-LISTEN:12345,reuseaddr,fork TCP6:[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]:12345 >> /dev/null 2>&1 &
nohup socat UDP6-LISTEN:12345,reuseaddr,fork UDP6:[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]:12345 >> /dev/null 2>&1 &


正文完
 
评论(没有评论)