主动FTP与被动FTP
FTP(文件传输协议)是一组标准的网络规则(协议),涉及两台主机之间通过基于TCP/IP的网络(使用传输控制协议/Internet协议将字节流从一台计算机传送到另一台计算机的网络)上的文件传输。FTP基于客户机/服务器原理,属于OSI模型(开放系统互连模型)的应用层。
通常,存储要传输的文件的FTP服务器使用两个端口进行传输,一个用于命令,另一个用于发送和接收数据。来自客户端计算机的请求在服务器的端口21接收,该端口专门用于发送命令;因此,它被称为命令端口。一旦接收到传入请求,客户端计算机请求或上载的数据将通过称为数据端口的单独端口进行传输。此时,根据FTP连接的主动或被动模式,用于数据传输的端口号会有所不同。
What is Active FTP?
Active FTP connection mode is where Command connection is initiated by the Client, and the Data connection is initiated by the Server. And as the server actively establishes the data connection with the Client, this mode is referred to as Active. The Client opens up a port higher than 1024, and through it connects to the port 21 or the command port of the Server. Then the Server opens up its port 20 and establishes a data connection to a port higher than 1024 of the Client. In this mode, Client must set its firewall settings to accept all the incoming connecti*** that are received at the opened port.
What is Passive FTP?
In the Passive FTP connection mode, the server acts entirely passively as the Command connection and the Data connection are both initiated and established by the Client. In this mode, Server listens for incoming requests through its port 21 (command port), and when a request is received for a data connection from the Client (using a high port), Server randomly opens up one of its High ports. Then Client initiates a data connection between the opened port of the Server and its own randomly selected port higher than 1024. In this mode, the Client does not have to change its firewall settings, as it only requires outgoing connecti*** and the firewall do not block outgoing connecti***. However, the Server administrators must make sure that the Server allows incoming connecti*** at all its opened ports.
What is the difference between Active FTP and Passive FTP?
The difference between the Active FTP and Passive FTP is based on who initiates the Data connection between the Server and the Client. If data connection is initiated by the Server, the FTP connection is active, and if the Client initiates the Data connection, FTP connection is passive.
Depending on the Active or Passive mode of the connection, port used for Data connection changes. In an Active FTP, data connection is established between port 20 of the Server and High Port of the Client. On the other hand, in Passive FTP, data connection is established between a High port of the Server and a High port of the Client.