FTP is a TCP based service exclusively. There is no UDP component to FTP. FTP is an unusual service in which it utilizes two ports, a ‘data’ port and a ‘command’ port (also known as the control port). Port 21 is used as the command port and port 20 for the data port. The confusion begins however, when we find that depending on the mode, the data port is not always on port 20. Let’s talk about these modes:

Active vs. Passive FTP

Active and passive are the two modes that FTP can run in. FTP uses two channels between client and server, the command channel and the data channel, which are actually separate TCP connections. The command channel is for commands and responses, the data channel is for actually transferring files. It’s an efficient way of sending commands to the server without having to wait for the current data transfer to finish.

In active mode, the client establishes the command channel (from client portX to server port 21) but the server establishes the data channel (from server port 20 to client port Y, where has been supplied by the client).

In passive mode, the client establishes both channels. In that case, the server tells the client which port should be used for the data channel.

Passive mode is generally used in situations where the FTP server is not able to establish the data channel. One of the major reasons for this is network firewalls. While you may have a firewall rule which allows you to open up FTP channels to ftp.talentcookie.com, Talentcookie’s servers may not have the power to open up the data channel back through your firewall.

Passive mode solves this by opening up both types of channel from the client side. Let’s try to understand the concept in different way:

Active mode:
  • Client opens up command channel from client port 2500 to server port 21.
  • Client sends PORT 2501 to server and server acknowledges on command channel.
  • Server opens up data channel from server port 20 to client port 2501
  • Client acknowledges on data channel.
Passive mode:
  • Client opens up command channel from client port 2500 to server port 21.
  • Client sends PASV to server on command channel.
  • Server sends back (on command channel) PORT 1234 after starting to listen on that port.
  • Client opens up data channel from client 2501 to server port 1234.
  • Server acknowledges on data channel.

At this point, the command and data channels are both open.


Installation of FTP server in LINUX

As in any other Ubuntu like Linux systems, installation of the FTP server comes down to a single command. Open up your terminal and enter the command:

$ sudo apt-get install vsftpd

The above command will install and start the ftp server on your Linux system.

Setting up vsftpd (2.3.5-1ubuntu2) ...
vsftpd start/running, process 1891

I hope things are less faded now. If you liked our post, please comment and let us know your feedback.

Related Posts

Leave a Reply

Your email address will not be published.