I need an automatic UPnP port forwarding or single port forwarding software/tool for Windows. i want to do the port forwarding automatically the way that i choose a port like 4545 on the software/tool and it should open that port for the computer's IP when it connects to the Internet.

I need to install the software/tool on a Laptop for someone who doesn't know port forwarding and connects to the Internet in multiple places with routers that some of them may be public so can't change the routers's settings. i need to have access to some apps in order to do work or assist him remotely like Real VNC. I've tried programs like this or Portmapper, unfortunately none of them are automatic.

  • Workaround: Can't you email the client a batch script that does the port forwarding for them and instruct them how to run the script? You could also configure it to take the port number as an argument so they could use it on multiple occasions – Tymric Mar 18 '15 at 12:58
  • @Timmy That would be a good idea, i could even use a Macro program to run the script at start up but i don't know how to script. – user6306 Mar 18 '15 at 13:44


Port forwarding can be accomplished in command line using the built-in netsh utility. If you have remote administrator access, then you could run the tool using the console. If not, then it could be saved into into a batch script which the could be run by the client (or started on a schedule).

Here is a question on StackOverflow whose answer uses netsh to forward ports. In the example they used, is forwarded into The format would be:

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

You can replace the addresses and port numbers with your required ones and save the command in an executable batch file, forward_port.bat for example.

If you want to use a different port number each time, then you could add arguments for the batch file using %+ digit. For example:

@echo off
netsh interface portproxy add v4tov4 listenport=%1 listenaddress= connectport=80 connectaddress=

You could run it using forward_port.bat 4422 for example, either directly from the command line or from another batch script.

  • Okay so i disabled manual port forwarding on my router (UPnP is enabled) and i typed this in the command line of the computer where VNC server is running. "netsh interface portproxy add v4tov4 listenport=5900 listenaddress= connectport=5900 connectaddress=", it didn't open the port 5900. i replaced the connect address with the router's default gateway (, still not opening the port. both VNC server and viewer are on the same physical network but different subnets. i could connect to the server with manual port forwarding on router before. – user6306 Mar 18 '15 at 15:06
  • Should the script do the port forwarding using UPnP? – user6306 Mar 18 '15 at 15:08
  • @Saeed The connectport should be the target port. Also, you should make sure that IPv6 protocols are installed, as per this page – Tymric Mar 18 '15 at 15:16
  • @Saeed I'm not sure about UPnP, and I can't test it right now. However, you could try it with both modes. You can enable/disable UPnP also within the same script by adding netsh firewall set service type = upnp mode = enable or netsh firewall set service type = upnp mode = disable (source) – Tymric Mar 18 '15 at 15:22
  • IPv6 is by default installed on my network adapter when i go to its properties. i turned off the Windows firewall yet i don't know what we're missing because it's not working right now. – user6306 Mar 18 '15 at 15:33


Create a new port mapping for a specific IP address:
java -jar portmapper.jar -add -externalPort <port> -internalPort <port> -ip <ip-addr> -protocol tcp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy