{"id":141,"date":"2021-06-18T19:35:17","date_gmt":"2021-06-18T14:05:17","guid":{"rendered":"https:\/\/chennaiwebhosting.in\/blog\/?p=141"},"modified":"2021-06-18T19:55:21","modified_gmt":"2021-06-18T14:25:21","slug":"configuring-ftp-passive-ports-range-in-cpanel-server","status":"publish","type":"post","link":"https:\/\/chennaiwebhosting.in\/blog\/configuring-ftp-passive-ports-range-in-cpanel-server\/","title":{"rendered":"Configuring FTP Passive ports range in cPanel server"},"content":{"rendered":"<p>FTP uses two ports, a data port and a command port, to transfer information between a client and a <a href=\"https:\/\/www.chennaiwebhosting.in\/chennai-dedicated-server.html\">server<\/a>. 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\u00a0<em>active<\/em>\u00a0mode, 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=\"size-full wp-image-144 aligncenter\" src=\"https:\/\/chennaiwebhosting.in\/blog\/wp-content\/uploads\/2021\/06\/Active-FTP.jpg\" alt=\"\" width=\"393\" height=\"172\" srcset=\"https:\/\/chennaiwebhosting.in\/blog\/wp-content\/uploads\/2021\/06\/Active-FTP.jpg 393w, https:\/\/chennaiwebhosting.in\/blog\/wp-content\/uploads\/2021\/06\/Active-FTP-300x131.jpg 300w\" sizes=\"auto, (max-width: 393px) 100vw, 393px\" \/><\/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=\"size-full wp-image-145 aligncenter\" src=\"https:\/\/chennaiwebhosting.in\/blog\/wp-content\/uploads\/2021\/06\/active-FTPfirewall.jpg\" alt=\"\" width=\"431\" height=\"241\" srcset=\"https:\/\/chennaiwebhosting.in\/blog\/wp-content\/uploads\/2021\/06\/active-FTPfirewall.jpg 431w, https:\/\/chennaiwebhosting.in\/blog\/wp-content\/uploads\/2021\/06\/active-FTPfirewall-300x168.jpg 300w\" sizes=\"auto, (max-width: 431px) 100vw, 431px\" \/><\/p>\n<p>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\u00a0<em>passive<\/em>\u00a0mode, the FTP client initiates both connection attempts. NAT configurations do\u00a0<strong>not<\/strong>\u00a0block this connection request.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-146 aligncenter\" src=\"https:\/\/chennaiwebhosting.in\/blog\/wp-content\/uploads\/2021\/06\/passiveFTP.jpg\" alt=\"\" width=\"432\" height=\"232\" srcset=\"https:\/\/chennaiwebhosting.in\/blog\/wp-content\/uploads\/2021\/06\/passiveFTP.jpg 432w, https:\/\/chennaiwebhosting.in\/blog\/wp-content\/uploads\/2021\/06\/passiveFTP-300x161.jpg 300w\" sizes=\"auto, (max-width: 432px) 100vw, 432px\" \/><\/p>\n<p>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 class=\"fittexted_for_content_h4\"><strong>How to Enable the passive port range for Pure-FTPd<\/strong><\/h4>\n<p>Login to your server\u00a0SSH\u00a0with root, edit the pure-FTPd configuration file with below command and search for \u201cPassivePortRange\u201d<\/p>\n<pre>[root@chennaiweb ~]# 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@chennaiweb ~]# 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@chennaiweb ~]# nano \/var\/cpanel\/conf\/pureftpd\/main\r\n\r\n. . . .\r\n. . . .\r\nMaxLoad: 4\r\nMinUID: 100\r\nNoAnonymous: &#039;yes&#039;\r\nPassivePortRange: 30000 45000\r\nProhibitDotFilesRead: &#039;no&#039;\r\nProhibitDotFilesWrite: &#039;no&#039;\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@chennaiweb ~]# \/usr\/local\/cpanel\/bin\/build_ftp_conf\r\n[root@chennaiweb ~]# \/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\u00a0<a href=\"https:\/\/configserver.com\/cp\/csf.html\" target=\"_blank\" rel=\"noopener nofollow\">CSF<\/a>, to add this port range in csf use the below command.<\/p>\n<pre>[root@chennaiweb ~]# nano \/etc\/csf\/csf.conf\r\n\r\n# Allow incoming TCP ports\r\nTCP_IN=&quot;20,21,22,25,53,80,110,143,443,465,587,2082,2083,2086,2087,2095,2096,30000:45000&quot;\r\n\r\n# Allow outgoing TCP ports\r\nTCP_OUT = &quot;20,21,22,25,37,43,53,80,110,113,443,587,873,993,995,2086,2087,2089,2703,30000:45000&quot;<\/pre>\n<p>Include the Passive Port range and reload the csf<\/p>\n<pre>[root@chennaiweb ~]# csf -r<\/pre>\n<p>Hope this article helps you, please share your comments to improve better.<\/p>\n","protected":false},"excerpt":{"rendered":"<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. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":151,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[14,13,6,11],"tags":[55,54,56],"class_list":["post-141","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos-6-rhel-6","category-centos-7-rhel-7","category-howtos","category-linux","tag-enabling-passive-ftp","tag-passive-ftp","tag-passive-ftp-port"],"_links":{"self":[{"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":4,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":143,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/141\/revisions\/143"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/media\/151"}],"wp:attachment":[{"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}