Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why not using SO_REUSEADDR on Unix TCP/IP servers?

I have not seen any important TCP/IP server not use SO_REUSEADDR :

  • Apache HTTP Server SO_REUSEADDR usage
  • nginx SO_REUSEADDR usage
  • Very Secure FTPD SO_REUSEADDR usage
  • exim SO_REUSEADDR usage
  • Postfix SO_REUSEADDR usage
  • OpenSSH SO_REUSEADDR usage

Is there any use case for not using SO_REUSEADDR on TCP/IP servers ?

I mean, would making the OS always use SO_REUSEADDR break any server that does not use it?

Do you know a TCP/IP server that not uses SO_REUSEADDR for a reason?

(of course you may not want to use it on MSWindows as it allows to run two servers on the same port)

like image 558
Eduardo Avatar asked Aug 05 '11 17:08

Eduardo


People also ask

What does the SO_REUSEADDR socket option do?

The SO_REUSEADDR socket option has four different functions: (1) SO_REUSEADDR allows you to start a listening server and bundle well-known ports, even though previously established ports still exist as their local ports. This condition is usually met as follows: A) Start a listening server;

How to restart a TCP server on the same port?

All TCP servers should specify this socket option to allow the server to be restarted in this case. (2) SO_REUSEADDR allows multiple instances of the same server to be started on the same port as long as each instance is bundled with a different local IP address.

How to disable TCP port reuse on remote stack?

If your answer to that is that the remote stack should do something like TIME_WAIT on its side to disallow ephemeral TCP port reuse, that solution assumes that the remote host is benign. A malicious actor is free to reuse that remote port.

Is the SO_REUSEADDR socket option secure?

As long as SO_REUSEADDR socket option can be used to potentially hijack a port in a server application, the application must be considered to be not secure. All server applications must set SO_EXCLUSIVEADDRUSE for a strong level of socket security.


1 Answers

Well, UNP (Stevens 2004) says:

SO_REUSEADDR allows a listening server to start and bind its well-known port, even if previously established connections exist that use this port as their local port.

All TCP servers should specify this socket option to allow the server to be restarted

like image 200
cnicutar Avatar answered Oct 20 '22 21:10

cnicutar