当有人连接到myIP:123时,我希望我的服务器(Ubuntu)将其连接redirect到其他IP:456。 连接到其他港口显然应该正常处理。 我很确定这将与iptables完成,我只是不知道这个规则是什么。 我知道我将如何做它作为HTTPredirect,但这不是HTTP。
我会做这样的事情:
iptables -t nat -A PREROUTING -p tcp --dport 123 -j DNAT --to-destination otherserver:456 iptables -t nat -A POSTROUTING -j MASQUERADE
但是这意味着你在sysctl中打开了IP转发。 /etc/sysctl.conf net.ipv4.ip_forward=1
你可以使用iptables来redirect端口/ ip。
例子在这里给出:
http://www.debuntu.org/how-to-redirecting-network-traffic-a-new-ip-using-iptables
或者你可以安装rinetd,我认为这更容易。 我通常使用rinetd。