by Michal Rogozinski
8. August 2009 10:07
FTP is based on Transmission Control Protocol (TCP) and has a connection. It has no connectionless User Datagram Protocol (UDP) component. FTP requires two ports for communication: a command port and a data port. Port 21 is typically the command port at the server; port 20 is the typical data port then using active mode FTP.
Active mode FTP communications is the default mode and starts with the client selection of two ports: n and n+1. The client will use port n to initiate communications to port 21 of the server. When the server responds, the client sends a port command. This command instructs the server which port to use for data communications. It is the server that initiates data communications from port 20 to the client’s data port (n+1). If the client has a firewall installed, the server may be blocked from initiating communications to the client on the data port.
Passive mode FTP communications can be used to correct the problem with active mode communications. Passive mode starts with the client selection of two ports: n and n+1. The client uses port n to initiate communications to port 21 of the server. When the server responds, the client sends a pasv command to the server, the server selects a random port p to use for data communications and sends the port (n+1) to the server’s data port (p).
Notice than when using passive mode, the client initiates communications on the command and data ports. This fixes the problem of the client having a firewall installed that blocks the server’s request to initiate communications on the data port.