windows windows中的端口转发

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11525703/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:42:03  来源:igfitidea点击:

port forwarding in windows

windowswindows-7portforwarding

提问by user1256477

I have two network board in my pc:

我的电脑中有两个网卡:

The main one has the local ip -> 192.168.1.111 The secondary ones has the local ip -> 192.168.0.200

主要有本地 ip -> 192.168.1.111 次要有本地 ip -> 192.168.0.200

The main one has internet connection and the second one is connected to a device with the IP 192.168.0.33, it has a http server in port 80.

主要的有互联网连接,第二个连接到 IP 为 192.168.0.33 的设备,它在端口 80 上有一个 http 服务器。

I have an apache-server in the main connection (port 4422), and I can access from anywhere, what I want now is when I detect a connection from 4422 i want to redirect this connection to 192.168.2.33:80

我在主连接(端口 4422)中有一个 apache-server,我可以从任何地方访问,我现在想要的是当我检测到来自 4422 的连接时,我想将此连接重定向到 192.168.2.33:80

How can I do this with windows?

我怎么能用窗户做到这一点?

回答by user1256477

I've solved it, it can be done executing:

我已经解决了,它可以完成执行:

netsh interface portproxy add v4tov4 listenport=4422 listenaddress=192.168.1.111 connectport=80 connectaddress=192.168.0.33

To remove forwarding:

要删除转发:

netsh interface portproxy delete v4tov4 listenport=4422 listenaddress=192.168.1.111

Official docs

官方文档

回答by Jonas Lundgren

nginxis useful for forwarding HTTP on many platforms including Windows. It's easy to setup and extend with more advanced configuration. A basic configuration could look something like this:

nginx可用于在包括 Windows 在内的许多平台上转发 HTTP。使用更高级的配置可以轻松设置和扩展。基本配置可能如下所示:

events {}

http {
     server {

        listen 192.168.1.111:4422;

        location / {
            proxy_pass http://192.168.2.33:80/;
        }
     }
}

回答by voon

I've used this little utility whenever the need arises: http://www.analogx.com/contents/download/network/pmapper/freeware.htm

每当需要时,我都会使用这个小实用程序:http: //www.analogx.com/contents/download/network/pmapper/freeware.htm

The last time this utility was updated was in 2009. I noticed on my Win10 machine, it hangs for a few seconds when opening new windows sometimes. Other then that UI glitch, it still does its job fine.

上次更新此实用程序是在 2009 年。我注意到在我的 Win10 机器上,有时打开新窗口时它会挂起几秒钟。除了 UI 故障之外,它仍然可以正常工作。