FTP (File Transfer Protocol) is TCP based service. FTP is widely used for transferring files over a network. There are various FTP servers are available to use like vsftpd, proftpd, pureftpd etc.
FTP uses two different ports –
1. Port 20 is used for the data port, But the data port is not always on the 20 port. It may change in passive mode.
2. Port 21 is used as command port.
FTP works in two different modes Active FTP and Passive FTP as per server and client configuration. In this article, I am trying to define Active FTP vs Passive FTP in a definitive explanation, I hope this will help you to understand its working.
Active FTP
In Active mode FTP, the client connects from any random unprivileged port ( For example ‘X’ ( greater than 1023 ) ) to FTP Server port 21. The client again sends the ‘X+1’ port to the FTP server which is acknowledged on the command channel. After that FTP server opens the data channel on port 20 to Clients port X+1.
- FTP client opens up command channel from client on port 1050 (1050 is for example only) to server port 21.
- FTP client sends PORT 1051 (1050 + 1) to FTP server and server acknowledges on command channel.
- FTP Server opens up data channel from server port 20 to client port 1051.
- FTP client acknowledges on data channel.
Passive FTP
In Passive mode FTP, the client connects from any random unprivileged port (For example ‘X’ (greater than 1023)) to FTP Server port 21. After that client sends a PASV signal to the FTP server command channel to inform the server for using passive mode. FTP server sends back on an unprivileged port (For example ‘Y’ (greater than 1023)). Now FTP client opens the data channel on ‘X+1’ to FTP server PORT ‘Y’. Which acknowledges by the FTP server.
- FTP client opens up command channel from client on port 1050 (1050 is for example only) to server port 21.
- FTP client sends PASV command to server on command channel.
- FTP server sends back (on command channel) PORT 1250 (1250 for example only) after starting to listen on that port.
- FTP client opens up data channel from client 1051 to server port 1250.
- FTP server acknowledges on data channel.
I hope the above details may help you understand the difference between Active FTP vs Passive FTP, We are waiting for your comments for whether this article is helpful or not helpful for you. Read our next article, how to download and upload files with ftp.
3 Comments
Good post..giving clear views..
Hey Rahul,
Thank you for the explanation. I hadn’t understood what a passive FTP was before reading this post. Your writing is clear and easy to understand.
Thanks,
Dennis
After reading other articles, this one is the clearest to me. Now I understand completely. Thank you so much. Thumbs up.