By default, FTP commands typically use TCP port 21.
Understanding FTP Ports
The File Transfer Protocol (FTP) is designed to use separate channels for commands and data transfer. This dual-channel approach provides flexibility and efficiency.
Based on the provided reference, "when FTP commands cross the wire, they use TCP port 21 by default." This means that the connection used to send commands like GET
, PUT
, LIST
, login credentials, etc., is established on port 21. This connection is often referred to as the control connection.
While port 21 handles the command traffic, the actual file data transfer happens on a separate connection, known as the data connection. The port used for the data connection varies depending on whether the FTP session is in active or passive mode.
FTP Ports Overview
Here's a quick look at the main ports used by FTP:
Port | Protocol | Purpose | Default Usage |
---|---|---|---|
21 | TCP | Control Channel | Commands & Session Mgmt |
20 | TCP | Data Channel | Active Mode Data (from server to client) |
>1023 | TCP | Data Channel | Passive Mode Data (negotiated) |
- Port 21 (Control): As highlighted by TechTarget and commonly known, this is the standard port for initiating the FTP connection and managing the session. It's used for sending commands from the client to the server and receiving responses.
- Port 20 (Data - Active Mode): In active mode, the FTP server initiates the data connection back to the client's specified data port (often port 20, but can be negotiated). This mode requires the client to open a port and listen for the server connection.
- Ephemeral Ports (Data - Passive Mode): In passive mode, the client initiates both the control and data connections. The server tells the client which port it is listening on for the data connection. These ports are typically high-numbered ephemeral ports (>1023, often in the 49152-65535 range), selected by the server.
Understanding the role of both the control (port 21) and data ports is crucial for configuring firewalls and network security to allow FTP traffic.