How to change the FTP port in CentOS 7?
To change the FTP port on CentOS 7, follow these steps:
- Open the FTP server configuration file vsftpd.conf.
- Open the vsftpd.conf file using the command “sudo vi /etc/vsftpd/vsftpd.conf.”
- Find and edit the following lines:
- The port for listening is 21.
- Change port number 21 to the new port number you want to use.
- 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.
- 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 - If you are using iptables, please use the following command for operations:
- Add a rule to allow incoming TCP traffic on the new port number, save the iptables rules, and restart the iptables service.
- Restart the vsftpd service to apply the changes.
- 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.