将定向到端口5000的包重定向到另一个端口

我正在尝试使用eboard连接到FICS服务器(http://www.freechess.org),但由于端口5000被阻止(公司防火墙),它失败了。 但是,我可以通过telnet端口(23)连接到服务器:

telnet freechess.org 23 (succeeds) telnet freechess.org 5000 (fails) 

不幸的是,端口号是硬编码的(见这里: http : //ubuntuforums.org/archive/index.php/t-1613075.html )。 我宁愿不必破解源代码,因为该线程的作者最终做了。 我可以使用iptables转发本地计算机上的端口吗? 我试过了:

 sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5000 -j REDIRECT --to-port 23 

 sudo iptables -t nat -I OUTPUT --src 0/0 -p tcp --dport 5000 -j REDIRECT --to-ports 23 

但这些都不起作用……

注意:

 $ sudo iptables -t nat -L Chain PREROUTING (policy ACCEPT) target prot opt source destination REDIRECT tcp -- anywhere anywhere tcp dpt:5000 redir ports 23 Chain INPUT (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination REDIRECT tcp -- anywhere anywhere tcp dpt:5000 redir ports 23 Chain POSTROUTING (policy ACCEPT) target prot opt source destination 

-j REDIRECT重定向到您自己的计算机。 如果要重定向到远程计算机上的其他端口,请使用-j DNAT --to-destination :23