Work around router upnp shortcomming implementations (Netgear CBVG834G)

Some router seem to implement the upnp protocol in a very trivial manner which doesn’t support the full discovery protocol. The router mentioned above, only sends broadcasts every N minutes and doesn’t react to the discovery messages.

In order to work around this, you can adapt the miniupnpc parameters in the firewall.py file to trick it into believing the router responded to the discovery broadcast !

Edit the file /usr/lib/moulinette/yunohost/firewall.py

And look around line 346. You should find this:

    # Refresh port mapping using UPnP
    if not no_refresh:
        upnpc = miniupnpc.UPnP()
        upnpc.discoverdelay = 3000

Change that to:

   # Refresh port mapping using UPnP
    if not no_refresh:
        upnpc = miniupnpc.UPnP()
        upnpc.discoverdelay = 62000
        upnpc.localport = 1900

This will tell miniupnp to wait longer than the resend time of the router and to bind to the local 1900 port for sending the request. This is the port the router is sending it’s response to.

Once the change is done, you can run:

yunohost firewall upnp enable

1 Like

(Note that a PR has been created implementing this : https://github.com/YunoHost/yunohost/pull/542 )