0 / 4
Active Mode
A client wants to download a file from an FTP server. FTP uses two connections: a control connection for sending commands and a data connection for carrying the file. In active mode, the server opens the data connection toward the client.
Which side opens the data connection: the server
1 / 4
Open the control connection
The client connects to port 21 on the server first and logs in. Commands travel over this connection, and it stays open until the file has been received.
2 / 4
The client announces its port
The client sends PORT to the server over the control connection. PORT: an FTP command that tells the server which of the client's own ports (port 50001) will receive the data. The client keeps that port open and waits for the server.
3 / 4
The server opens the data connection
The server connects from its port 20 to the client's port 50001. From the client's side this is a connection coming in from outside first, so a firewall often blocks it.
4 / 4
Transfer the file
Once connected, the server sends the file content over this data connection. When it is done, the data connection closes and only the control connection remains.
1 / 4
Open the control connection
The client connects to port 21 on the server first and logs in. Commands travel over this connection, and it stays open until the file has been received.
2 / 4
The server opens a data port and announces it
The client sends PASV to the server over the control connection. PASV: an FTP command that asks the server to open a port for the data connection and tell the client its number. The server opens a free port (port 2024), replies with that number, and waits for the client.
3 / 4
The client opens the data connection
The client connects to port 2024, the one the server announced. It is a connection going out from the client, so a firewall usually lets it through. In return, the server's firewall has to leave open the range of numbers the server uses for data ports.
4 / 4
Transfer the file
Once connected, the server sends the file content over this data connection. The client opened the connection, but the file flows from the server to the client.