What is the difference between ftp port numbers 20 and 21?

When I was doing the questions today, I found that one of the questions was written like this:

When the FTP client uploads files, the connection established through the server port 20 is (), and the port of the FTP client application process can be ().

A. Control connection established on TCP B. Data connection established on TCP

A. Control connection established over UDP B. Data connection established over UDP

A.20 B.21 C.80 D.4155

The answer is BD

Just use this question to learn more about FTP knowledge points:

The difference between ftp port numbers 20 and 21 is: one is the data port and the other is the control port . The control port is generally 21, but the data port is not necessarily 20. This is related to the application mode of FTP. If it is active mode, it should be 20 , if it is passive mode, it is determined by negotiation between the server and the client.

One is the data port and the other is the control port. The control port is generally 21, while the data port is not necessarily 20. This is related to the application mode of FTP. If it is active mode, it should be 20. If it is passive mode, it is determined by the server and Depends on client negotiation

        FTP Port mode and FTP Passive mode

  When you are troubleshooting an FTP problem, one of the first questions you should ask is whether you are using port mode or passive mode. Because these two behaviors are very different, the problems caused by these two modes are also different; in the past, the client defaulted to active (port) mode; recently, due to the security issues of Port mode, many client FTP applications defaulted to Passive model.

        >> FTP Port mode

  The steps for FTP in Port mode are as follows:

1. The client sends a TCP SYN (TCP synchronization) packet to the well-known FTP control port 21 of the server segment. The client uses the temporary port as its source port;

2. The server sends a SYN ACK (synchronization acknowledgment) packet to the client. The source port is 21 and the destination port is the temporary port used on the client;

3. The client sends an ACK (confirmation) packet; the client uses this connection to send FTP commands, and the server uses this connection to send FTP responses;

4. When the user requests a list request or initiates a request to send or receive a file, the client software uses the PORT command. This command contains a temporary port that the client hopes the server will use when opening a data connection. Temporary port; the PORT command also contains an IP address. This IP address is usually the client's own IP address, and FTP also supports third-party mode. In third-party mode, the client tells the server to open a connection with another host. Connection;

5. The server sends a SYN packet to the client's temporary port. The source port is 20. The temporary port is the temporary port number sent by the client to the server in the PORT command;

6. The client uses the source port as the temporary port and the destination port as 20 to send a SYN ACK packet;

7. The server sends an ACK packet;

8. The host sending the data uses this connection to send the data, and the data is sent in the form of TCP segment (note: segment, PDU of layer 4) (some commands, such as STOR indicates that the client wants to send data, RETR indicates that the server segment sends data) , these TCP segments require ACK confirmation from the other party (note: because the TCP protocol is a connection-oriented protocol)

9. When the data transmission is completed, the host sending the data ends the data connection with a FIN command. This FIN command requires confirmation from the other host with ACK. The other host also sends a FIN command. This FIN command also needs to send data. The host confirms with ACK;

10. The client can send more commands on the control connection, which can open and close other data connections; sometimes after the client ends, the client closes a control connection with the FIN command, and the server confirms it with an ACK packet The client's FIN, the server also sends its FIN, and the client confirms it with ACK.

Guess you like

Origin blog.csdn.net/qq_29855509/article/details/126703610