将请求重定向到外部IP /端口到另一个外部IP /端口?
是否可以将连接重定向到特定的IP /端口到外部IP /端口?
例:
- 服务器A具有外部IP xxx.xxx.xxx.xxx
- 服务器B具有外部IP yyy.yyy.yyy.yyy
- 用户在端口2106上向服务器A发送请求,我想在端口2106将其重定向到服务器B.
问题解决了:
sysctl net.ipv4.ip_forward=1 iptables -t nat -A PREROUTING -p tcp --dport port -j DNAT --to-destination ip:port iptables -t nat -A POSTROUTING -j MASQUERADE
其中ip和port是目标服务器,我想将当前服务器端口重定向到。