Iptables block ftp access

Completely disable the FTP access on the server using below iptables rule:

iptables -A INPUT -p tcp –dport 21 -j DROP

If you want to block FTP access for a Specific IP then run the below command:

 iptables -A INPUT -p tcp -s –dport 21 -j DROP

To Disable FTP access for Specific Subnet:

 iptables -I INPUT -p tcp -s –dport 21 -j DROP

After adding the adding rules you need to save the rules by running the command:

/etc/init.d/iptables save

Then to apply the above saved rules, restart the IPtables by running the command:

/etc/init.d/iptables restart