How to change the FTP port in CentOS 7?

To change the FTP port on CentOS 7, follow these steps:

  1. Open the FTP server configuration file vsftpd.conf.
  2. Open the vsftpd.conf file using the command “sudo vi /etc/vsftpd/vsftpd.conf.”
  3. Find and edit the following lines:
  4. The port for listening is 21.
  5. Change port number 21 to the new port number you want to use.
  6. If you are using a firewall, please add a new FTP port rule to the firewall. Here is an example of how to do this using firewalld.
  7. Add the new port to the firewall in the public zone permanently using the following command:
    sudo firewall-cmd –permanent –zone=public –add-port=new port number/tcp
    Then reload the firewall using:
    sudo firewall-cmd –reload
  8. If you are using iptables, please use the following command for operations:
  9. Add a rule to allow incoming TCP traffic on the new port number, save the iptables rules, and restart the iptables service.
  10. Restart the vsftpd service to apply the changes.
  11. restart the vsftpd service using systemctl

Your FTP server will now be running on a new port number. Make sure to use the new port number when connecting from the client side.

bannerAds