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 10.10.10.10 –dport 21 -j DROP

To Disable FTP access for Specific Subnet:

 iptables -I INPUT -p tcp -s 10.10.10.10/24 –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