Ftp – Why port 20 is not used for data channel in FTP passive mode

ftp

In the active mode, an FTP server uses two ports, 21 for command signals, and 20 for data. In the passive mode in FTP, after the client connects to the server at port 21, the server the server gives the client a random ephemeral port to connect to, for the data connection, on which it starts listening. Why doesn't the server give port 20 (as is usual for active mode) for the data connections?

PS: I have looked at Why does FTP passive mode require a port range as opposed to only one port? but that does not address my specific question.

Best Answer

I do not know why original authors of FTP specification decided this way. But this decision has advantages with the way how Internet works now these days.

If you were to connect to the same port (20) every time, the server would not be able to tell, what file do you connect for. The port number serves as a link between a transfer request on the control connection and a data connection. Note that there's no "protocol" on the data connection, that could be used by the client to tell what it asks for. The port number is the only unique information the server has.

If two clients were to request a transfer at the same time, and the server were accepting data connections on the single port, the server would not be able to tell, what file to transfer. Of course, the server could use a client IP for the decision (actually many FTP server do validate that the client IP matches the IP used on the control connection for security).

But this would not work for:

  • Multiple connections from the same machine (most FTP clients do support parallel transfers/queues).
  • Connection from different machines withing the same (corporate) network, as those have the same external IP.

Neither of the above was probably the reason why FTP specification introduced a port range, as at the time (1980) corporate networks did not exist and multiple connections from the same machine were probably also unlikely. On the other hand at those times the port range may significantly simplify the server implementation.