命令简介
yum在线安装
yum install socat -y
端口转发
在转发服务器上执行命令:
socat TCP-LISTEN:8080,fork,reuseaddr TCP:192.168.2.3:80 &
测试访问:
curl 192.168.2.3
curl 192.168.2.10:8080
原理说明
socat转发的优势
socat相比于iptables配置更简单,只需要一条命令即可实现转发功能,而iptables不仅需要配置转发命令,还需要在Linux内核中开启转发功能。
后台运行示例
socat TCP-LISTEN:8080,fork,reuseaddr TCP:192.168.2.3:80 nohup