UPnP PortMapper is an easy to use program that manages the port mappings (port forwarding) of a UPnP enabled internet gateway device (router) in the local network. You can easily view, add and remove port mappings.
Using port forwarding, it is possible to access servers (SSH, Web, Game servers, ...) running in a private network from the internet. Port mappings can be configured using the web administration interface of a router, but using the UPnP PortMapper is much more convenient: Just create a new preset or select an existing preset and click one button to add a port mapping for your current computer, the IP address is retrieved automatically!
The interface is written in English and German. PortMapper automatically selects the language according your operating system.
See CHANGELOG.md for changes in the new version.
UPnP PortMapper requires JRE 11 (Java Runtime Environment) or later. I recommend you download OpenJDK 11 JRE from AdoptOpenJDK.
For Windows please choose the
.msi installer which will set the environment variable
JAVA_HOME and add java to the
Verify that the installation was successful by running this command:
$ java -version openjdk version "11.0.3" 2019-04-16 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)
To run PortMapper, double click on the JAR file or run
$ java -jar portmapper.jar
on the command line.
Error 1: When you double click
portmapper.jar an error dialog with message
A JNI error has occurred, please check your installation and try again is displayed.
Error 2: When you start PortMapper from the command line using
java -jar portmapper.jar you get the following exception:
java.lang.UnsupportedClassVersionError: org/chris/portmapper/PortMapperStarter has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Usually this means your Java version is outdated. Please install Java 11 or later. If this does not help: run PortMapper from the command line using
java -jar portmapper.jar and create a ticket containing the stack trace.
DummyRouterFactoryis just for testing.
TRACEin the settings, connect again and check the log.
If you can connect to your router from one device but not from another you can directly specify the location URL.
Note: this is only supported for library weupnp (
Infobutton (look for something like
INFO - location = http://192.168.178.1:49000/igddesc.xml)
$ java "-Dportmapper.locationUrl=<locationurl>" -jar portmapper.jar -lib org.chris.portmapper.router.weupnp.WeUPnPRouterFactory <args>
DummyRouterFactoryis just for testing.
If you have multiple routers in your network please use library
org.chris.portmapper.router.sbbi.SBBIRouterFactory. After connecting a dialog will allow you to select one of the found routers.
org.chris.portmapper.router.cling.ClingRouterFactory currently only supports one router.
If you have a high resolution display and the fonts (e.g. the log) in PortMapper is too small, please upgrade to Java 9 or later. See http://openjdk.java.net/jeps/263 for details.
Some routers delete port mappings after some time. To avoid this you can use the command line interface of PortMapper to add the port mapping in an infinite loop. Under Windows you can use a
.cmd script like this:
:loop rem Add port mapping java -jar portmapper.jar -add -externalPort <port> -internalPort <port> -protocol tcp rem Wait for 6 hours (6*60*60 seconds) timeout 21600 goto loop
Ctrl+C to stop the infinite loop.
See the command line interface section for details about using the command line interface and available options.
Sometimes you get a log message like this:
Got error response when fetching port mapping for entry number 0: '(IncomingActionResponseMessage) 500 Internal Server Error'. Stop getting more entries.
This error message is expected. UPnP does not allow getting the total number of available port mappings. That's why PortMapper continues fetching the mappings until it receives an error like this one. You can ignore these messages, they don't mean there is a problem.
PortMapper also has a command line interface. You can see the available options by adding parameter
$ java -jar portmapper.jar -h -add : Add a new port mapping -delete : Delete a new port mapping -description VAL : Description of the port mapping -externalPort N : External port of the port mapping -gui : Start graphical user interface -h (-help) : Print usage help -info : Print router info -internalPort N : Internal port of the port mapping -ip VAL : Internal IP of the port mapping (default: localhost) -lib VAL : UPnP library to use -list : Print existing port mappings -protocol [TCP | UDP] : Protocol of the port mapping -routerIndex N : Router index if more than one is found (zero-based)
$ java -jar portmapper.jar -add -externalPort <port> -internalPort <port> -ip <ip-addr> -protocol tcp
$ java -jar portmapper.jar -add -externalPort <port> -internalPort <port> -protocol tcp
$ java -jar portmapper.jar -delete -externalPort <port> -protocol tcp
$ java -jar portmapper.jar -list
$ java -jar portmapper.jar -lib org.chris.portmapper.router.weupnp.WeUPnPRouterFactory -list
PortMapper includes three third party UPnP libraries. If the default does not work for your device, try using a different library.
org.chris.portmapper.router.dummy.DummyRouterFactory(for testing only)
PortMapper is translated to English (
en) and German (
de). It automatically detects the operating system's language using English as default. If you want use a different language, add command line option
-Duser.language=de to java, e.g.:
$ java -Duser.language=de -jar portmapper.jar
PortMapper stores its configuration as XML files in a folder. Under Windows this folder is located at
C:\Users\<username>\AppData\Roaming\UnknownApplicationVendor\PortMapper). You can change this folder by specifying a command line argument:
java -Dportmapper.config.dir=C:/path/to/config -jar portmapper.jar
Create an empty directory before starting, else PortMapper will fail with an error message.
The configuration files are only used when PortMapper runs in GUI mode. When running in command line mode the configuration files are not used. Instead you must specify all settings as command line arguments.
Build PortMapper on the command line:
$ git clone https://github.com/kaklakariada/portmapper.git $ cd portmapper $ ./gradlew build $ java -jar build/libs/portmapper-*.jar
$ ./gradlew licenseFormat
Add your bintray credentials to
bintrayUser = <user> bintrayApiKey = <apiKey>
Increment version number in
README.md, commit and push.
Run the following command:
$ ./gradlew clean check bintrayUpload --info
Create a new release on GitHub.
Your feedback is most welcome at the project page: