这是我们的情况,我们想要进入我们的服务器的stream量一个IP发送(隧道)到服务器B上的特定IP,并接受从服务器B回到服务器A的答复。这怎么可以用iptables完成?
确保双向通信的服务器通过服务器在iptables规则之后运行:
# this will forward all the relevant traffic to the server b iptables -t nat -A PREROUTING -p tcp --dport 1234 -d ip.address.of.a -j DNAT --to ip.address.of.b:1234 # and this will make sure there's no triangular routing - all packets forwarded to b # will have source ip address of a, return communication will always go via a iptables -t nat -A POSTROUTING -p tcp --dport 1234 -d ip.address.of.b -j MASQUERADE
如果只是转发是不够的 – 我build议你在a和b之间build立一个vpn [使用openvp,ipsec或只是ssh端口转发和一个看门狗],并应用类似的防火墙规则。
在linux中,你只需为你的发行版安装rinetd并configuration参数,就完成了。
Windows也有一个端口: http : //www.ehowstuff.com/how-to-install-and-configure-port-forwarding-using-rinetd-in-windows/
是的,iptables可以做到这一点,但我一直使用rinetd,因为它更直接。