FTP active mode, passive mode

Hello, everyone! I’m Yibodong , a network engineer from Cisco who specializes in Huawei; well, not much to say, let’s go straight to the topic.

Topology

Insert picture description here

LSW1

[Huawei]sysname LSW1  //设备的名称
[LSW1]stp disable     //关闭STP功能

Insert picture description here

Client1

Configure IP address: 100.1.12.1/24

Insert picture description here
Server1

Configure IP address: 100.1.12.2/24

Insert picture description here

server

Server Information—>FtpServer—>Select a file

Insert picture description here
start up

Insert picture description here
Client

FTP active mode

There are two FTP three-way handshake. The first TCP three-way handshake is the control layer's handshake, and the second is the data layer's TCP three-way handshake.

Client Information—>FtpClient—>Fill in the IP address of the server: 100.1.12.2—>Select the "PORT" command, this is the active mode—>Login

Insert picture description here
Logged in successfully
Insert picture description here
capture
Insert picture description here

(1) The server opens port 21 and waits for a connection;
(2) The client (100.1.12.1) initiates a request for establishing a control connection, and the server responds to the connection and controls the establishment of the connection, using the TCP three-way handshake (the first TCP three-way handshake);

Insert picture description here
100,1,12,1,8,10

Client 100.1.12.1, temporary port number =8*256+10=2058

(3) The client sends the PORT command (with its own ip address and temporary port in the application layer data) through the control connection, and tells the server the temporary port number of the client's data connection
(4) The server's port 20 and the client Establish a data connection, using TCP three-way handshake (the second TCP three-way handshake);

FTP passive mode

There are two FTP three-way handshake. The first TCP three-way handshake is the control layer's handshake, and the second is the data layer's TCP three-way handshake.

Client information—>FtpClient—>Fill in the IP address of the server: 100.1.12.2—>Select the "PASV" command, this is the active mode—>Login

Insert picture description here

Capture

Insert picture description here
(1) The server opens port 21 and waits for the connection.
(2) The client initiates a control connection establishment request. The server responds to the connection and controls the connection establishment, using the TCP three-way handshake (the first TCP three-way handshake);

Insert picture description here
14 0.203000 100.1.12.2 100.1.12.1 FTP 98 Response: 227 Entering Passive Mode (100,1,12,2,8,1)

Server 100.1.12.2, temporary port number =8*256+1=2049

(3) The client sends the command word PASV through the control connection to inform the server that the server is in passive mode;
(4) The server responds, telling the client the temporary port number (2060) of the server's data connection;
(5) The temporary port between the client and the server Establish a data connection, using TCP three-way handshake (the second TCP three-way handshake);

It is impossible for a successful person to succeed alone or alone. Someone has to support you.


Insert picture description here
Well, this issue is here. If you like this article, please like, comment and share the collection. If you can still click and follow, that is really my biggest encouragement. Thank you, see you in the next issue!

Guess you like

Origin blog.csdn.net/HYD696/article/details/115284551