如何将 UDP 流量从一个公共 IP (linux) 路由到另一个公共 IP (Windows)

Mah*_*iya 3 ip route forwarding linux-networking

我想阻止直接访问我的 Windows 计算机,并希望通过我的 Linux 计算机(同样可以通过公共 IP 访问)公开在其上运行的一些程序。

有没有一种方法可以配置我的 Linux 机器(比如 IP = ),将其在特定端口(比如 )获得的a.b.c.d)所有流量路由到我的 Windows 机器(比如 IP = )的端口?UDP6667e.f.g.h6668

是的,我该如何实施呢?

更新

# bindadress    bindport  connectaddress  connectport

192.168.2.45    6667    192.168.2.104   6668

# logging information
logfile /var/log/rinetd.log

# uncomment the following line if you want web-server style logfile format
logcommon
~          
Run Code Online (Sandbox Code Playgroud)

更新

UDP只想路由流量。

Man*_*tha 5

以下部分仅适用于 TCP(这是在 Mahendra 更改标题之前发布的)

安装rinetd。在此程序中,您可以轻松配置传入端口和传出端口。首先安装该程序。然后更改/etc/rinetd.conf

前任:

#bindadress bindport connectaddress connectport

a.b.c.d 6667 e.f.g.h 6668

对于 UDP,请检查下面的链接

http://brokestream.com/udp_redirect.html

这是来自实际解决问题的聊天讨论

iptables -t nat -A PREROUTING -i $EXT_IF -p udp -d $EXT_IP --dport 53 -j DNAT --to-destination $INTERNAL_SERVER

and make sure you also have it allowed to pass through the FORWARD chain with something like

#forward traffic
iptables -A FORWARD -i $EXT_IF -o $INT_IF -p udp -d $INTERNAL_SERVER --dport 53 -j ACCEPT
#reply traffic
iptables -A INPUT -o $EXT_IF -i $INT_IF -p udp -s $INTERNAL_SERVER --sport 53 -m state --state ESTABLISHED,RELATED -j ACCEPT
Run Code Online (Sandbox Code Playgroud)