Solution to "227 Entering Passive Mode" when FTP connection appears (practical case attached)

The solution to "227 Entering Passive Mode" appears during FTP connection.
Some time ago, a simple FTP server was built on the local win7 to test the batch messages generated on the linux server. Initially, there was no problem when the test was set up, but again today When testing from ftp on linux to ftp-server on the local win7 host, the following error is always reported

I double-checked the ftp-server configuration, everything is OK! Finally, I found that FTP originally had two working modes, active and passive mode. I failed to connect in passive mode. After I successfully connected to the remote host, I used passive to close the passive mode of the client, and the data was transferred normally. The two working modes of FTP are listed below.

FTP has two working modes, PORT mode and PASV mode, which means active and passive in Chinese. The details are as follows:

Active FTP:
    Command connection: client>1024 port → server 21 port
    Data connection: client>1024 port ← server 20 port

Passive FTP:
    Command connection: client>1024 port → server 21 port
    Data connection: client>1024 port ← server>1024 port

The connection process in PORT (active) mode is: the client sends a connection request to the server's FTP port (the default is 21), the server accepts the connection, and establishes a command link. When data needs to be transmitted, the client uses the PORT command on the command link to tell the server: "I opened the ***X port, you come and connect to me". So the server sends a connection request from port 20 to port ***X of the client, and establishes a data link to transmit data.

The connection process in PASV (passive) mode is: the client sends a connection request to the server's FTP port (the default is 21), the server accepts the connection, and establishes a command link. When data needs to be transmitted, the server uses the PASV command on the command link to tell the client: "I opened the ***X port, you come to connect to me". Then the client sends a connection request to the ***X port of the server to establish a data link to transmit data.

Since my local FTP server only maps two ports (20, 21) from the external network, my local FTP server cannot use the PASV method. The solution to this problem is also very simple. Turn off the client's PASV method and force it to use PORT To access the server, use the passive command to close the PASV mode of the client after logging in to the FTP server, as follows:

ftp> passive
  Passive mode off.

ftp> passive (run the command again to open)

Passive mode on.

related articles

  1. Solution to "227 Entering Passive Mode" when FTP connection
  2. Linux expect问题集:227 Entering Passive Mode (10,41,49,10,218,187). ftp: connect: Connection timed out
  3. 227 The solution to Entering Passive Mode!
  4. [Solve FTP] Windows access to Linux vsftpd (FTP server) problem 200 Switching to ASCII mode, 227 Entering Passive Mode
  5. vsftp problem "227 Entering Passive Mode"
  6. FTP Server random link abnormal-Passive mode
  7. The solution of "227 Entering Passive Mode" appears when linux system accesses win2003 FTP connection
  8. The configuration and difference of ftp's active mode and passive mode
  9. vsftp login error: 227 Entering Passive Mode

Guess you like

Origin blog.csdn.net/weixin_43214644/article/details/115024316