iptables本地端口转发到远程端口

# Now, to forward port 9999 on host 192.168.202.103 to port 80 on host 192.168.202.105
# we need to add the following rules to the iptables configuration of host 192.168.202.103:
sudo iptables -t nat -A PREROUTING -p tcp --dport 9999 -j DNAT --to-destination 192.168.202.105:80
sudo iptables -t nat -A POSTROUTING -p tcp -d 192.168.202.105 --dport 80 -j SNAT --to-source 192.168.202.103
sudo iptables -t nat -L -n

其他端口转发工具:https://y4er.com/post/port-forwarding/

例如socat:

./socat TCP4-LISTEN:local_port,fork TCP4:remote_ip:remote_port

 

Leave a Reply

Your email address will not be published.