How to Change FTP Port in Linux

FTP or File Transfer Protocol is one of the oldest network protocol used today as standard file transfers over computer networks. FTP protocol uses the standard port 21/TCP as command port. Although, there are a lot of implementations of FTP protocol in server-side in Linux, in this guide we’ll cover how to change the port number in the Proftpd service implementation.

In order to change Proftpd service default port in Linux, first open Proftpd main configuration file for editing with your favorite text editor by issuing the below command. The opened file has different paths, specific to your own installed Linux distribution, as follows.

# nano /etc/proftpd.conf            [On CentOS/RHEL]
# nano /etc/proftpd/proftpd.conf    [On Debian/Ubuntu]

In proftpd.conf file, search and comment the line that begins with Port 21. You need to add a hashtag (#) in front of the line in order to comment the line.

Then, under this line, add a new port line with the new port number. You can add any TCP non-standard port between 1024 to 65535, with the condition that the new port is not already taken in your system by other application which binds on it.

In this example we’ll bind FTP service on port 2121/TCP.

#Port 21
Port 2121
Change FTP Port in Debian & Ubuntu

Change FTP Port in Debian & Ubuntu

In RHEL based distributions, the Port line is not present in Proftpd configuration file. To change the port, just add a new port line at the top of the configuration file, as illustrated in the below excerpt.

Port 2121
Change FTP Port in CentOS & RHEL

Change FTP Port in CentOS & RHEL

After you’ve changed the port number, restart the Proftpd daemon to apply changes and issue netstat command to confirm that FTP service listens on the new 2121/TCP port.

# systemctl restart proftpd
# netstat -tlpn| grep ftp
# ss -tlpn| grep ftp
Confirm FTP Port

Confirm FTP Port

Under CentOS or RHEL Linux based distributions, install policycoreutils package and add the below SELinux rules in order for the FTP daemon to bind on the 2121 port.

# yum install policycoreutils
# semanage port -a -t http_port_t -p tcp 2121
# semanage port -m -t http_port_t -p tcp 2121
# systemctl restart proftpd

Finally, update your Linux distribution firewall rules in order to allow inbound traffic on the new FTP port. Also, check FTP server passive port range and make sure you also update the firewall rules to reflect passive port range.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Matei Cezar

I'am a computer addicted guy, a fan of open source and linux based system software, have about 4 years experience with Linux distributions desktop, servers and bash scripting.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

2 Responses

  1. kiran says:

    nano /etc/proftpd/proftpd.conf blank file with this message: there is no file.

  2. Ice Alinutza says:

    I run Linux Mint 19 MATE 64 bit and command:

    # nano /etc/proftpd/proftpd.conf

    Oen a blank file with this message:

    [ Directory '/etc/proftpd' does not exist ]

    My connection is DSL (no router) and is make with command “sudo pppoeconf” and work fine!

    What happens???

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.