14

Is there any client that can request mapping and unmapping ports via UPnP port mapping behind a NAT gateway? I had problem with PortMap. I want this mostly for testing purposes.

Atilla Filiz
  • 1,116
  • 4
  • 14
  • 20
  • 1
    It should be noted that many sysadmins disable UPnP on their routers because of a long history of security vulnerabilities in both implementation and design. – hackerb9 Aug 05 '20 at 19:56

3 Answers3

13

Use upnpc from MiniUPnP.

For gateways supporting the NAT-PMP protocol, natpmpc is available from the same site.

u1686_grawity
  • 426,297
  • 64
  • 894
  • 966
6

Complementing @user1686 answer. This is how you can do it on Ubuntu, Mint and all Debian based distros:

# Install upnpc command line
sudo apt install -y miniupnpc

# Get network ip address (typically started with 192)
export IP=$(hostname -I | tr " " "\n" | grep 192)

# External port 2222 forwarded to internal port 22
upnpc -e "upnpc test" -a $IP 22 2222 TCP

# Delete
upnpc -d 2222 TCP
Eduardo
  • 323
  • 4
  • 9
  • 1
    And if you use a firewall, you have to enable UDP packets coming from the router. In my case, I use `ufw`, so the command would be something like this `sudo ufw allow from 192.168.1.1 to any proto udp` – Madacol Nov 05 '22 at 18:28
3

I found upnp-router-control that make it possible to do it with a beautiful GUI interface.

eloyesp
  • 543
  • 5
  • 18