Skip to content

natpmpc open a random port #29

@stokito

Description

@stokito

I have a webserver on a port 8000 and need to expose it with natpmpc on WAN on any random port. So then I'll simply generate a link to it and share.
But currently I have to specify explicitly the external port:

natpmpc -a 8000 8000 tcp

The problem here is that I don't know if this external 8000 port is not already taken or allowed by the miniupnpd. So that's why I can't rely on this.
Basically the local port 9000 may be also busy and it would be also useful if the natpmpc can also take some random and free port (maybe ephemeral).

Maybe it can be something like:

natpmpc -a rand rand tcp

Is it possible to implement something like this? Or the PCP spec requires to specify the requested port?

Ideally the natpmpc should print the port numbers to stdout in form

loc_port ext_ip ext_port

Then it would be easy to parse with a script.
Any other logging messages of the natpmpc may be printed to stderr so that a script needs to parse only clear stdout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions