Is this how ftp works?

7

3

I just want to check if my understanding of ftp is correct. An ftp server listens at port 21. A client establishes a connection to the ftp server using a local ephemeral port that connects to the ftp server's port 21. When the ftp server sends a file to the client, it sends it from port 20, to an ephemeral port on the client's computer that is different from the one used to connect to port 21.

Is that correct? Also, what happens if multiple computers try to contact the ftp server at the same time? Do they all connect to port 21? Is there a limit to the number of simultaneous connections that can be open at a port?

tony_sid

Posted 2011-02-21T10:39:12.353

Reputation: 11 651

Answers

14

Your understanding is correct.

A server port can always be accessed by multiple clients, because a TCP session is identified by 4 elements: client IP address + client port + server IP address + server port, not by the server port only.

There is also an FTP passive mode, in which it is the client that initiates the data connection to an ephemeral port on the server. This allows passing FTP traffic through some firewall or NATting devices.

philfr

Posted 2011-02-21T10:39:12.353

Reputation: 266

1

I found http://slacksite.com/other/ftp.html the best site to help understand the difference between active and passive FTP. You're recommended to read it.

– Lekensteyn – 2011-02-21T16:27:55.813