What is FTP?
File Transfer Protocol (FTP) is the protocol that actually lets you transfer files across an IP network, and it can accomplish this between any two machines that are using it. But FTP isn’t just a protocol; it’s also a program. Operating as a protocol, FTP is used by applications. As a program, it’s employed by users to perform file tasks by hand. FTP also allows for access to both directories and files and can accomplish certain types of directory operations, such as relocating files into different directories.
How does FTP work?
Unless you configure your FTP server differently, you will normally set your command channel to use FTP port 21. The FTP port you'll use for the data channel, on the other hand, can differ depending on which data transfer mode you choose. If you choose the active mode, then the data channel will normally be FTP port 20. But if you choose the passive mode, then the port that will be used will be a random port.
Active Mode FTP
The Active mode can be summarized in two steps.
Passive Mode FTP
In passive mode, the client still initiates a command channel ( control connection) to the server. However, instead of sending the PORT command, it sends the PASV command, which is basically a request for a server port to connect to for data transmission. When the FTP server replies, it indicates what data port number it has opened for the ensuing data transfer.
Active Mode vs Passive Mode FTP: Which Is More Suitable For You?
The above diagrams show how the active and passive modes of the FTP work, for the active mode the second arrow is pointing to the client. that means the client initially specifies which client-side port it has opened up for the data channel, and the server initiates the connection. By contrast, in the passive mode, the second arrow is pointing to the server. Here, the server specifies which server-side port the client should connect to and the client initiates the connection.
In an active mode configuration, the server will attempt to connect to a random client-server port. So chances are, that port wouldn’t be one of the predefined ports. As a result, an attempt to connect to it will be blocked by the firewall and no connection will be established.