15

Is there a utility to forward ports on a simple home networking wireless router from commandline using upnp?

2 Answers2

15

Check out MiniUPNP Project.

Wesley
  • 4,505
  • 2
  • 22
  • 43
  • 3
    To install on Ubuntu: `sudo apt install miniupnpc` To add a port forward: `upnpc -a 192.168.1.2 22 3333 TCP` To remove a port forward: `upnpc -d 3333 TCP` Info from https://po-ru.com/2013/02/17/using-upnp-igd-for-simpler-port-forwarding – Heath Mitchell Oct 01 '20 at 17:35
2

You can use the miniupnpc library test client.
Use $ upnpc -r PORT PROTOCOL to automatically forward port to your current machine.

Example:

$ upnpc -r 13 TCP

…forwards port 13 to local port 13 when TCP is used.

On correct execution it will print a message like:

external 203.0.113.0:13 TCP is redirected to internal 192.168.1.5:13 (duration=604800)

…where 192.168.1.5 is your LAN IP and 203.0.113.0 you WAN (public Internet) IP.