主動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.