In general ephemeral ports are used by clients when establishing connection with the server.
For example:
- Server listens on port 80
- A client (browser, FTP client, bittorent client) send a request to server including ephemeral port assigned by OS
- Server responds using provided ephemeral port as destination port
And now the question:
I wrote a server application which I would like to start on random free port each time it is started (To keep this question consist I will not explain why I would like this behaviour). Now my question is what implications would it have if I use one of ephemeral ports for server to listen on. Are there any drawbacks (also in terms of security) of doing this?
Do you maybe know any example of a server that is also make use of ephemeral ports in practise?
One of my concerns is also statement from The TCP/IP Guide: A Comprehensive, Illustrated Internet Protocols Reference (page 705):
Just as well-known and registered port numbers are used for server processes, ephemeral port numbers are for client processes only.