将数据包转发到一个地址,以便本地应用程序监听不同地址

我有一个计算机有两个接口eth1与10.223.75.53和eth2与192.168.1.1。 Eth2没有连接网线,但是在端口5000上的192.168.1.1上有应用程序侦听,假设这个应用程序是netcat。 Eth1连接到networking。 networking上的一些应用程序会使用10.223.75.53:5000进行tcp连接,所以我想把10.223.75.53:5000上的所有stream量redirect到192.168.1.1:5000。

我尝试了以下规则:

iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 5000 -j DNAT --to-destination 192.168.1.1 

推出服务器:

 netcat -l -p 5000 192.168.1.1 # local server 

并试图沟通:

 netcat 10.223.75.53 5000 

服务器崩溃的信息:

 netcat -l -p 5000 192.168.1.1 invalid connection to [10.223.75.53] from (UNKNOWN) [10.223.75.53] 49116 

客户刚退出。

我的路由表是:

 $ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.223.75.1 0.0.0.0 UG 100 0 0 eth1 10.223.75.0 0.0.0.0 255.255.255.0 U 100 0 0 eth1 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2 $ ip rule ls 0: from all lookup local 32766: from all lookup main 32767: from all lookup default 

我不明白我的规则有什么问题。