search
HomeCommon ProblemWhat is the difference between ftp port numbers 20 and 21?

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 should be 20. If it is passive mode, it is determined by negotiation between the server and the client.

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

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

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 FTP application mode. If it is active mode, it should be 20. If it is passive Mode, determined by negotiation between the server and the client

FTP Port mode and FTP Passive mode

When you troubleshoot an FTP problem, the first question you have to ask is to use Is it in 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.

 >>2.1 FTP Port mode

The FTP steps in Port mode are as follows:

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

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

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 is 20 to send a SYN ACK packet;

7. The server sends an ACK packet;

8. The host sending the data uses This connection is used to send data, and the data is sent in the form of TCP segments (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 each other Perform ACK confirmation (Note: Because the TCP protocol is a connection-oriented protocol)

9. After the data transmission is completed, the host sending the data ends the data connection with a FIN command. This FIN command requires another The host confirms with ACK, and the other host also sends a FIN command. This FIN command also requires the host sending the data to confirm with ACK;

10. The client can send more commands on the control connection. This Additional data connections can be opened and closed; sometimes after the client ends, the client uses the FIN command to close a control connection, and the server uses an ACK packet to confirm the client's FIN. The server also sends its FIN, and the client uses ACK to confirm.

For more computer-related knowledge, please visit the FAQ column!

The above is the detailed content of What is the difference between ftp port numbers 20 and 21?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)