1、iptables NAT转发

1
2
3
4
5
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 19200 -j DNAT --to-destination 192.168.1.160:22
iptables -t nat -A POSTROUTING -d 192.168.1.160/32 -p tcp -m tcp --sport 22 -j SNAT --to-source 192.168.1.7

iptables -t filter -A INPUT -p tcp -m state --state NEW -m tcp --dport 19200 -j ACCEPT
iptables -t filter -A INPUT -i eth1 -p tcp -m tcp --dport 9090 -m state --state NEW -j ACCEPT

2、socat 转发

1
2
yum install -y socat
socat TCP4-LISTEN:28222,reuseaddr,fork TCP4:192.168.9.1:22 &

3、nginx stream

1
2
3
4
5
6
7
8
stream {
 server {
  listen 31022;
  proxy_connect_timeout 10s;
  proxy_timeout 10s;
  proxy_pass 127.0.0.1:22;
 }
}

4、privoxy

1
2
3
4
yum -y install gcc gcc-c++ zlib zlib-devel openssl openssl-devel pcre pcre-devel autoconf popt-devel privoxy;

systemctl enable privoxy;
systemctl start privoxy;