{"id":92,"date":"2021-08-06T08:04:58","date_gmt":"2021-08-06T08:04:58","guid":{"rendered":"https:\/\/cloudlinuxhosting.in\/blog\/?p=92"},"modified":"2021-08-31T01:58:46","modified_gmt":"2021-08-31T01:58:46","slug":"configuring-ftp-passive-ports-range-in-cpanel-server","status":"publish","type":"post","link":"https:\/\/cloudlinuxhosting.in\/blog\/configuring-ftp-passive-ports-range-in-cpanel-server\/","title":{"rendered":"Configuring FTP Passive ports range in cPanel server"},"content":{"rendered":"<h1 class=\"post-title entry-title fittexted_for_single_post_title\">Configuring FTP Passive ports range in cPanel server<\/h1>\n<p>FTP uses two ports, a data port and a command port, to transfer information between a client and a server. During a typical active mode session, the command port uses port 21 and the data port uses port 20. When you use a passive mode, however, the data port does not always use port 20.<\/p>\n<p>Let see about, what is\u00a0 Active FTP and what is Passive FTP ?<\/p>\n<p><strong>ACTIVE FTP<\/strong><\/p>\n<p>In <em>active<\/em> mode, the FTP server responds to the connection attempt and returns a connection request from a different port to the FTP client. Network Address Translation (NAT) configurations block this connection request.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1563\" src=\"https:\/\/www.coimbatorewebhosting.com\/blog\/wp-content\/uploads\/2019\/04\/FTP-passive-pots.png\" alt=\"\" width=\"400\" height=\"168\" \/><\/p>\n<p>In the above figure, a user connects from a random port on a file transfer client to port 21 on the server. It sends the PORT command, specifying what client-side port the server should connect to. This port will be used later on for the data channel and is different from the port used in this step for the command channel.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1564 size-full\" src=\"https:\/\/www.coimbatorewebhosting.com\/blog\/wp-content\/uploads\/2019\/04\/FTP1.png\" alt=\"FTP\" width=\"431\" height=\"241\" \/>In the above figure, the server connects from port 20 to the client port designated for the data channel. Once connection is established, file transfers are then made through these client and server ports.<\/p>\n<p><strong>PASSIVE FTP<\/strong><\/p>\n<p>In <em>passive<\/em> mode, the FTP client initiates both connection attempts. NAT configurations do <strong>not<\/strong> block this connection request.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1565\" src=\"https:\/\/www.coimbatorewebhosting.com\/blog\/wp-content\/uploads\/2019\/04\/ftp2.png\" alt=\"\" width=\"432\" height=\"232\" \/>In the above figure, the client connects from a random port to port 21 on the server and issues the PASV command. The server replies, indicating which (random) port it has opened for data transfer.The client connects from another random port to the random port specified in the server\u2019s response. Once connection is established, data transfers are made through these client and server ports.<\/p>\n<h4>Active mode vs Passive mode &#8211; which is more convenient for you?<\/h4>\n<p>If you compare the above two diagrams, one things that should really stand out are the opposing directions at which the second arrows (which also represent the data channels) are pointing to.<\/p>\n<p><span id=\"hs_cos_wrapper_post_body\" class=\"hs_cos_wrapper hs_cos_wrapper_meta_field hs_cos_wrapper_type_rich_text\" data-hs-cos-general-type=\"meta_field\" data-hs-cos-type=\"rich_text\">Remember that in an active mode configuration, the server will attempt to connect to a <strong>random<\/strong> client-side port. So chances are, that port wouldn&#8217;t be one of those predefined ports. As a result, an attempt to connect to it will be blocked by the firewall and no connection will be established<\/span><\/p>\n<h4 class=\"fittexted_for_content_h4\"><strong>How to Enable the passive port range for Pure-FTPd<\/strong><\/h4>\n<p>Login to your server SSH with root, edit the pure-FTPd configuration file with below command and search for \u201cPassivePortRange\u201d<\/p>\n<pre>[root@coimbatorewebhosting~]# nano \/etc\/pure-ftpd.conf\r\n\r\n. . . .\r\n# Port range for passive connections replies. - for firewalling.\r\nPassivePortRange 30000 45000\r\n. . . .\r\n<\/pre>\n<p>Modify it as above, save the configuration file and restart the service<\/p>\n<pre>[root@coimbatorewebhosting ~]# service pure-ftpd restart<\/pre>\n<p>Note : Changes made directly to the \/etc\/pure-ftpd.conf file will be overwritten any time the configuration file is rebuilt, which could happen during updates. Changes made to the template file will be applied when the configuration file is rebuilt, so you will want to modify that so your changes are added if the file is rebuilt.<\/p>\n<p>Modify the template file with below command.<\/p>\n<pre>[root@coimbatorewebhosting ~]# nano \/var\/cpanel\/conf\/pureftpd\/main\r\n\r\n. . . .\r\n. . . .\r\nMaxLoad: 4\r\nMinUID: 100\r\nNoAnonymous: 'yes'\r\nPassivePortRange: 30000 45000\r\nProhibitDotFilesRead: 'no'\r\nProhibitDotFilesWrite: 'no'\r\n\r\n. . . . .\r\n<\/pre>\n<p>After modifying that, you can run this command to rebuild the ftp configuration file with your changes, then restart ftp.<\/p>\n<pre>[root@coimbatorewebhosting ~]# \/usr\/local\/cpanel\/bin\/build_ftp_conf\r\n[root@coimbatorewebhosting ~]# \/scripts\/restartsrv_ftpd<\/pre>\n<p>Now, you can able to connect FTP with Passive mode.<\/p>\n<p>Note : Make sure you have configured this passive port range in your <a href=\"https:\/\/configserver.com\/cp\/csf.html\" target=\"_blank\" rel=\"noopener noreferrer\">CSF<\/a>, to add this port range in csf use the below command.<\/p>\n<pre>[root@coimbatorewebhosting ~]# nano \/etc\/csf\/csf.conf\r\n\r\n# Allow incoming TCP ports\r\nTCP_IN=\"20,21,22,25,53,80,110,143,443,465,587,2082,2083,2086,2087,2095,2096,30000:45000\"\r\n\r\n# Allow outgoing TCP ports\r\nTCP_OUT = \"20,21,22,25,37,43,53,80,110,113,443,587,873,993,995,2086,2087,2089,2703,30000:45000\"<\/pre>\n<p>Include the Passive Port range and reload the csf<\/p>\n<pre>[root@coimbatorewebhosting ~]# csf -r<\/pre>\n<p>Hope this article helps you, please share your comments to improve better.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Configuring FTP Passive ports range in cPanel server FTP uses two ports, a data port and a command port, to transfer information between a client and a server. During a typical active mode session, the command port uses port 21 and the data port uses port 20. When you use a passive mode, however, the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":144,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-92","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/cloudlinuxhosting.in\/blog\/wp-json\/wp\/v2\/posts\/92","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudlinuxhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudlinuxhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudlinuxhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudlinuxhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=92"}],"version-history":[{"count":2,"href":"https:\/\/cloudlinuxhosting.in\/blog\/wp-json\/wp\/v2\/posts\/92\/revisions"}],"predecessor-version":[{"id":94,"href":"https:\/\/cloudlinuxhosting.in\/blog\/wp-json\/wp\/v2\/posts\/92\/revisions\/94"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudlinuxhosting.in\/blog\/wp-json\/wp\/v2\/media\/144"}],"wp:attachment":[{"href":"https:\/\/cloudlinuxhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=92"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudlinuxhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=92"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudlinuxhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=92"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}