I am looking for a way to prevent a specific process from binding to anything outside of a specific range of local ports. Lets say localhost:50000 - localhost:50050 is an allowed range. I am NOT looking for changing the range of ephemeral ports.
Is it possible to give a process rights to only a very specific range of local ports that it is allowed to bind to? This would be doable if my application were container-friendly, but I need to do this without a docker abstraction layer.
This application attempts a bind(0) where it will randomly pick 5 local ports to bind to.