Test UPnP port mapping with miniupnpc
Create, list and delete UPnP port mappings from the command line with miniupnpc.
miniupnpc is a command-line UPnP IGD client. It lets you list, create and delete port mappings on a UPnP-capable router, which is useful to check that a port forward works.
Get the tool
The Windows binary upnpc-static.exe is available on the project site: miniupnp.free.fr/files.
Main options
| Option | Role |
|---|---|
-a internal_ip internal_port external_port protocol |
Create a mapping |
-r port protocol [port protocol ...] |
Redirect the given ports to this machine |
-d external_port protocol |
Delete a mapping |
-l |
List the mappings |
Create a mapping
upnpc-static.exe -a 192.0.2.10 81 8081 tcp
Expected output:
external 192.0.2.11:8081 TCP is redirected to internal 192.0.2.10:81 (duration=0)
Redirect several ports to this machine
upnpc-static.exe -r 80 tcp 443 tcp 22 tcp
Delete a mapping
upnpc-static.exe -d 443 tcp
upnpc-static.exe -d 22 tcp
List the mappings
upnpc-static.exe -l
Notes
- UPnP must be enabled on the router.
- An open mapping exposes the internal service to the Internet: delete it after the test.
- The
192.0.2.xaddresses are placeholder values.