How are external ports assigned

  • Hi,

    I was just wondering how you go about finding an available external port on the nat box. I've tried to find something related in the sources to no avail. Am I seeing it right that the client requests a specific port and the igd installs the DNAT rule for it?
    What happens if the port is already in use by another DNAT mapping, "normal" masqueraded connection, a daemon or some other random connection on the nat box?
    I'm asking just out of curiosity concerning linux-igd but also as I'm planning to write some daemon that installs DNAT rules to handle edonkey clients on the internal network.
    Another thing out of curiosity: what about using libiptc instead of executing the iptables binary?


    • This is an old message, however I've been now adding libiptc-support for upnpd and can say that it's not so easy but very well doable. DNAT is in different module and usually loaded dynamically by iptables, but it's really easy to merge the module code statically to the actual binary. Another thing is kernel modules but they are probably autoloaded almost always these days, otherwise we would have to call modprobe and the benefit we get from using libiptc instead of iptables binary is very small.

  • It doesn't look like your first question was ever answered about having the external port be allocated for you.

    Is that correct?  That you didn't find a way to have this happen?

  • That's right, but then I haven't used linux-igd or UPNP in general for several years now.  So what you see in this thread is all there is to it I guess.