Hello Cynthia Wahome

You can write a shell script to block the IP sample in the file attached 

or you can block them from the IPTABLES platform 

  1. login into the shell as a root user  
  2. Run IP tables command ( iptables -A INPUT -s IP-ADDRESS -j DROP)
  3. To Limit or chuck access from an IP using a certain PORT eg 45 or 25
  4. # iptables -A INPUT -s 12.22.22.165 -p tcp --destination-port 45 -j DROP
  5. The above will simamisha all the packets coming from port 45 using the specified IP 
Hope it helpz.