Two modes of operation of FTP protocol: Active mode active and passive mode passive
FTP is a data transfer Protocol (File Transfer Protocol) that has two types of connection modes: Active mode (active) and passive mode (passive).
The following explains how the FTP connection was established:
In active mode (General preset mode):
FTP client opens a randomly selected TCP port to the Port 21 request for FTP server to establish a connection. When the Three-way handshake is completed, the connection is established successfully, but this is only the establishment of the command channel.
When the data is transmitted at both ends, the client tells the server through the command channel with a port command, and the client can use another TCP port as the data channel.
The server then establishes a data connection with Port 20 and the TCP port that the client has just told. Note: The connection direction is from server to client, and there will be a SYN flag in the TCP packet.
The client then returns a confirmation packet with an ACK flag and completes another three-way handshake process. At this point, the data connection can be successfully established. Start data transfer.
In passive mode:
FTP client opens a randomly selected TCP port to the Port 21 request for FTP server to establish a connection, completing the command channel establishment.
When the data is needed at both ends, the client sends a PASV command to the server via the command-line, requesting access to the passive transmission mode.
The server then selects a TCP port and tells the client in the command channel, as in the 2nd step of the above normal mode.
The client then uses another TCP port to call the TCP port that the server told just now to establish the data channel. In this case, a SYN flag is present in the group.
The server confirms that an ACK group is echoed back. and completes all handshake process, the successful establishment data channel.
Start data transfer. In practice, active mode is used to log in some FTP servers that have no firewall installed on the host, or to install FTP server! on the client side. Passive mode (PASV) is used to log on to some of the FTP installed on the firewall and is open on the host server!