Head Pic:視線
Socat 安装
Socat 的安装很简单,一般直接 yum(Centos)或者 apt-get(Ubuntu Debian)就能装。
yum install -y socat
apt-get update
apt-get install -y socat
Socat 使用
转发 TCP
nohup socat TCP4-LISTEN:30000,reuseaddr,fork TCP4:1.1.1.1:30000 >> socat.log 2>&1 &
转发 UDP
nohup socat -T 600 UDP4-LISTEN:10000,reuseaddr,fork UDP4:1.1.1.1:10000 >> socat.log 2>&1 &
Description
TCP4-LISTEN:10000 监听 ipv4 的 10000 端口
fork TCP4:1.1.1.1:10000 转发到 1.1.1.1 的 10000
nohup 后台运行,把这个命令写到 /etc/rc.local
里面开机自启。
总结
Socat 只能进行进行单端口的转发(可添加多个),不支持诸如 10000:20000 的多端口转发。操作简单是它最大的特点,多端口还是请用 iptables 或者 haproxy (未来会更新的,咕咕咕)