Universal Plug and Play (UPnP) is a set of networking protocols that permits networked devices to seamlessly discover each other's presence on the network and establish functional network services. Wikipedia
miniupnpc
Assuming your router already supports UPnP, you need to install a client to configure the port forwarding.
I'm from a mac so I use miniupnpc.
You can install it using brew:
brew install miniupnpc
Port forwarding
Let's say your server is running on your local-network on 192.168.0.10:5000
, and you want to access it from the internet.
You need to forward an incoming request on your public address to your local one, matching the port number.
Using miniupnpc:
upnpc -a 192.168.0.10 5000 7000 tcp
This means "Forward any incoming tcp requests on port 7000 to the local address 192.168.0.10, using port 5000".
That is! You can test it by accessing your public IP (you can google it)
curl http://your-public-ip:7000/
Other commands
Remove entry by port number
upnpc -r 5000
List entries
upnpc -l
Top comments (0)