Port Forwarding / Port Mapping on Windows Server 2008 R2

Rick Wargo

As a long time friend of linux’s itables command, I mistakenly assumed that trying to port forward on Windows Server 2008 R2 would be just as easy. After quite a long while of searching I was able to determine the correct command; through use of netsh on the command line, it is easy to map incoming TCP traffic from one port to another port.

In my scenario, I needed to have an SSL connection initiated on a port other than 443 on the same machine, but handled by a service listening on port 443. To do this, the following command is entered on the command line; in this example, port 12345 is used as the initiating port.

C:\Users\Administrator> netsh interface portproxy add v4tov4 listenport=12345 listenaddress=192.168.1.1 connectport=443 connectaddress=192.168.1.1

Port 12345 is mapped to port 443 on the same machine. To have the traffic transferred to another machine, change the ip address for the connect address to the desired ip address.

Share and Enjoy:
  • Facebook
  • Twitter
  • LinkedIn
  • StumbleUpon
  • del.icio.us
  • Google Buzz
  • Yahoo! Buzz
  • Digg
  • email

43 Responses to “Port Forwarding / Port Mapping on Windows Server 2008 R2”

  1. Chris T Says:

    THANK YOU, you saved my life with this!!!!

  2. Port Forwarding On Windows Server 2008 R2 » Help Desk Screeds Says:

    [...] Fortunately, this post saved the day! [...]

  3. Anthony A Says:

    Hi, How can we remove or delete what have done above. Thanks for the post.

  4. Tech Know how Says:

    netsh interface portproxy reset

    verify it

    netsh interface portproxy show all

    Thank you /?

  5. Edgar Ramos Says:

    Do you have to run the command every time you turn on your machine ?

  6. Rick Wargo Says:

    It appears to maintain the port mapping after reboot, Edgar.

    Thanks to Tech Know How for answering Anthony’s question!

  7. Reroute IP Traffic to another IP? - Admins Goodies Says:

    [...] blogpost with an example can be found here, further information on the netsh interface portproxy command is part of the Windows Server [...]

  8. Daniel Says:

    Thanks, you just saved another life, this was driving me crazy as well. It’s like the most basic routing function yet it’s not available via GUI…

  9. Stephen Says:

    You rock! This site indeed saved the day!

  10. jorge Says:

    one question. where can i manage the ports that i have already been forward, for example, i want to delete one…
    thanks

  11. Richard Says:

    It’s simple, why delete it when you can remap it. listen on: 127.0.0.1:3306 -> connect to: 127.0.0.3308, replace with 127.0.0.1:3306 -> connect to: 127.0.0.3306 – It updates the correct record and you can clearly see when you relist it, that you want the proxy removing, or make a batch file to clear the list and add them. EG:

    proxy.bat –
    netsh interface portproxy reset
    netsh interface portproxy add v4tov4 listenport=3306 listenaddress=127.0.0.1 connectport=3308 connectaddress=127.0.0.1
    netsh interface portproxy add v4tov4 listenport=80 listenaddress=127.0.0.1 connectport=8080 connectaddress=127.0.0.1
    – end of file

    Obviously, when you run the file, it will remove the list and reinsert your records, but you can also add this to startup if your machine isn’t remembering the list.

  12. Abhijit Says:

    It really released me for some time, till today.
    Now it is not working for me :(

    On Windows server 2008 R2 Enterprise I have Jboss running on 8080 port.

    I have configured 80 port forward to 8080 , even I can see proxy is being configured

    >netsh interface portproxy show all
    Listen on ipv4: Connect to ipv4:
    Address Port Address Port
    ————— ———- ————— ———-
    10.190.20.94 80 10.190.20.94 8080

    Command used to configure this forward is

    >netsh interface portproxy add v4tov4 listenport=80 listenaddress=10.190.20.94 connectport=8080 connectaddress=10.190.20.94

    but when I want to access
    http://10.190.20.94/
    It is not forward to port 8080

    firewall is off .
    Jboss is accesible directly using 8080 port.
    http://10.190.20.94:8080 Works fine

    Please help me to check where I need to check the problem.

    Thank you.

  13. Markus Says:

    Awesome. Thank you.

  14. Ann naccarato Says:

    Thank you so much. We struggled all morning till we found your command. AWESOME.

  15. Brett Says:

    THANK YOU so so so much!

  16. Phil Says:

    Very nice, thanks again!

  17. curist Says:

    Finally the actual “port forwarding” I’m looking for, thx so much :)

  18. Toby Says:

    Another one saying thanks.

    Found on google using: server 2008 redirect port

  19. rd Says:

    epic, thanks!

  20. Thomas Says:

    Thanks, saved my day!

  21. Mike Says:

    +1 Epic! Works on Windows 7 Home edition as well. I am using it to do port forwarding from incoming connections over neorouter to a non-neorouter capable IP device. (IP Thermostat). My cabin property is behind a double nat on Verizon Broadband. So I have a dyndns account on my computer at home with a routable IP. That forwards to the neorouter private address and the neorouter client on the cabin side forwards to the IP thermostat.

  22. Mahyar Says:

    Thank you so much
    I never thought that it would be possible,
    so I always said, well, I will install routeros one day! and do it that way.
    I googled “windows 2008 r2 port forwarding” maybe there is a way to do that on Windows Server 2008 R2,
    and luckily I arrived here by your answer. :-)

  23. ???? » Port Forwarding / Port Mapping on Windows Server 2008 R2 « epicblog Says:

    [...] Port Forwarding / Port Mapping on Windows Server 2008 R2 « epicblog. Categories: ????????????????? Tags: ??????????? (0) ??????????? (0) ???????? ??????????? ??????????? [...]

  24. Machupichu Says:

    YOU SAVE MY DAYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  25. canin Says:

    does this work with UDP ports

  26. Syed Says:

    Thanks ……..

  27. love u man Says:

    god bless you, dude…

  28. love u man Says:

    so here’s the question though… is this a NAT or a proxy? depending on how the underlying component is delivering this facility, it can be a substantial difference in terms of load. I.e., we’re separating a MSSQL instance from a server that hosts IIS web server to it’s own box…

    before:
    server1: IIS/web and MSSQL

    after
    server1: IIS/web =======> server2: mssql

    The plan is to use the port proxy on server1 to proxy server1′s 127.0.0.1:1433 ===> server2′s x.x.x.x:1433 so that no changes are needed to connection strings on server1 websites.

    My concern… load associated with this proxying, as server1 is heavily loaded. Again, NAT would be very low load, proxy would be more substantial.

    Appreciate any thoughts from anyone…

  29. Ravi Says:

    I am just wondering i forwarded port as 80 described on Server 2008 Enterprise (2 NIC) but do i need to disble forwrding port on modem (Billion)? Modem (DHCP disabled )
    but modem is still forwarding ports NIC 1 connected to server

  30. Zorrs Says:

    i have a Win 2008 server with 2 NIC. one is the 192.168.0.0 and 10.180.0.0…i have have NAT the 192.168.0.0 to 10.180.0.0…i am using CC proxy, and listen on port 808
    how can i redirect incoming request (from 192.168.0.1 NIC)to first to this port 808…

  31. ThomasP1975 Says:

    Hi and thanks for the solution!
    I have verified the portproxy functionality as described in this thread on a VMWare virtual machine running Windows 2008 r2 standard edition and it works great!
    However when I try to run the same command on a Windows 2008 R2 Hyper-V machine it does not work!
    I have also verified the the firewall settings and it all looks ok.

    Any help would be appreciated!

    Thanks in advance!
    /Thomas

  32. Mike Says:

    Super. Awesome. Thank-you!

  33. ed es Says:

    Chido banda, excelente aporte, nos ayudo bastante.

    Saludos y muchas gracias.

  34. Darren Says:

    Your awesome, thanks. D.

  35. James Says:

    I am having the same exact problem as Abhijit above….I’m at my wits end, does anyone have an ideas what this may be?

    Thanks

  36. Kashif Haroon Says:

    Works….

    Thanks.

  37. Jaesang Yang Says:

    Thanks!!!!!

  38. Benoit Says:

    I’m having the same issues as James and Abhijit … I’m not sure, but aside I run iis on the same machine, I tried it by shutting down iis, but problem persists. Pls help.

  39. Bukvoglot Says:

    For those who having the problems on win2008 –
    check the IP Helper service.

    It MUST be started.

    MS indeed should give a warning message while configuring port forward in that case… %)

  40. Sasha Says:

    Thanks !!!

  41. Equallogic PortForwarding and Server 2008 R2 | Michael Ellerbeck Says:

    [...] http://www.rickwargo.com/2011/01/08/port-forwarding-port-mapping-on-windows-server-2008-r2/ [...]

  42. jax7480 Says:

    Great!!! This worked like a charm for me.

    Great work!!!

  43. aduranv Says:

    Worked for me, thank you very much!!!

stop spam with honeypot!