

The first port is used to connect to the server's command port. With passive FTP, the FTP client initiates a connection via two random TCP ports N (command port) and N+1 (data port).

This is the case, for example, if the client is behind a firewall that uses NAT to rewrite the client's address. This method is used when the client is not directly accessible by the server. In the case of firewalls or NAT devices that are located upstream of the client, this could involve additional configuration effort on the client side, since the data port of the client behind the firewall must be accessible to the server (see figure "Connect 4243"). The server then connects to the client on port N+1 and uses its data port as the source port.Ī problem with active FTP is that the client itself does not establish a connection to the server's data port, but communicates a port (N+1) to the server, which then connects to the client via its data port. The client then listens on port N+1 and notifies the server of this port. With active FTP, the client connects to the command port of the FTP server. Depending on the connection mode, the two ports mentioned above are initiated differently, which is described in more detail below. With FTP, two connection modes are available for setting up such connections: " Active FTP" and " Passive FTP". Separate TCP connections are used for sending and receiving files (data port) and for transmitting commands (command port). Port 21/tcp: This port is generally referred to as command port and is used to exchange status information between the client and server.Port 20/tcp: This port is also referred to as data port and is used to send/receive files and directory lists.FTP specifies two TCP ports, which are important for data transfer: The File Transfer Protocol (FTP) is based exclusively on TCP-based communication connections.
