311

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

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.

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

How can I do this with windows?

1

3 Answers 3

635

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

12
  • 24
    Just be sure to have IPv6 installed. Accordingly to this MS KB article, netsh need some IPv6 libraries to configure the port proxy feature. Commented Mar 30, 2013 at 5:26
  • 23
    Also, you can do cleanup using netsh interface portproxy reset or netsh interface portproxy delete
    – patrikbeno
    Commented May 12, 2015 at 13:39
  • 7
    I tried using this technique, and while it worked, it was extremely slow. Instead. I found a utility called PassPort (sourceforge.net/projects/pjs-passport) that does the same type of port forwarding bound to a specific NIC, but does not have the performance issues of netsh. It installs and runs well on Win2008SvrR2.
    – James L.
    Commented Oct 10, 2015 at 22:03
  • 18
    The command above didn't work for me on Windows7 nor on Windows Server 2003. I had to specify protocol=tcp parameter too. Full command: netsh interface portproxy add v4tov4 listenport=4422 listenaddress=192.168.1.111 connectport=80 connectaddress=192.168.0.33 protocol=tcp
    – alwi
    Commented Sep 15, 2016 at 10:17
  • 5
    NOTE that this only works on TCP, so no luck if you wanted to forward UDP traffic.
    – user276648
    Commented Dec 13, 2016 at 7:13
17

nginx is 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:

events {}

http {
     server {

        listen 192.168.1.111:4422;

        location / {
            proxy_pass http://192.168.2.33:80/;
        }
     }
}
5
  • 20
    This is a good solution for HTTP forwarding, but only for HTTP forwarding (with all its caveats, e.g. websockets need additional config). For HTTPS forwarding or other arbitrary protocols (e.g. RDP) it's mostly useless. Commented Jul 9, 2016 at 1:19
  • 2
    That said, it's an incredibly good solution for HTTP forwarding, so I'm glad it's here.
    – Casey
    Commented Apr 11, 2017 at 22:16
  • Why is that? You can stream forward whatever you like, including https Commented Jun 4, 2018 at 13:46
  • @uli which settings do you tolking about ... It will be usefull to share Commented Nov 20, 2018 at 7:19
  • 2
    @UliKöhler Nginx is a tool to decouple TCP connections. You can use it for HTTP, HTTPS, AMQP, WebSockets, whatever. It's used internally by tools all over for redirecting and managing general TCP connectivity. So, this is the correct solution. See also netfxharmonics.com/2016/03/nginx
    – David Betz
    Commented Jan 15, 2019 at 15:45
8

I've used this little utility whenever the need arises: 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.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.