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

13 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.

Leave a Reply

stop spam with honeypot!