问题原文
原帖链接 · Maxime · CC BY-SA 4.0
I need a client application to connect to a server in a different network. Another computer is connected to both networks as shown here:
Client Computer Server
192.168.1.10 <---------> 192.168.1.20 192.168.2.30 <---------> 192.168.2.40
network 1 network 2
(wifi) (ethernet)
I need the middle computer (Windows) to act as a router to forward any connection to port 502 to the server. Network 2 is an internal network of an industrial machine, so I'd like to keep it separate from the main network 1 as much as possible, and avoid reconfiguring routers. That means only connecting to the middle computer and redirecting the packets from there if possible.
What is the best way to achieve this?
I already tried netsh interface portproxy add v4tov4 listenport=502 listenaddress=192.168.1.20 connectport=502 connectaddress=192.168.2.40 which works well, but only until the next reboot. If the rule is created or activated just before the wifi connects, it doesn't work, even though it is still visible in netsh interface portproxy show all. Only deleting and recreating the rule, or restarting the iphlpsvc service can get it to work again. Is there a way to fix this?
Is there a better tool, or a better way to do it, like using simple routing or a similar technique? Or are NAT and port forwarding required?
已采纳解答
原帖链接 · Maxime · CC BY-SA 4.0
As suggested in the comments, the simplest solution is to use listenaddress=0.0.0.0 which does seem to make netsh portproxy more reliable.
A better way to do it would be to use or develop a proxy application.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
