How to Block an IPaddress on CentOS, Fedora and Redhat Linux Server

 
You must have server root access to blacklist / Block the IPaddress on Linux server. Steps to drop Incoming connection from an IPaddress to the Linux server is given below :
 

How to Drop / Block Incoming connection from an IP address on a linux server

 
Step 1: Log into your Linux server via SSH as ‘root’ user

Step 2: Run the command “iptables -A INPUT -s IPADDRESS -j DROP” to block the IP address

Step 3: Run the command “service iptables save” to save the IPtables rules

‘IPADDRESS’ in Step 2 should be replaced with the IP address you wish to Block.
 

How to Drop / Block Outgoing connection to a specific IP address

 
Step 1: Log into Linux Server via SSH as ‘root’ user

Step 2: Run the command “iptables -A OUTPUT -d IPADDRESS -j DROP”

Step 3: Save the IPtables Rules by running the command “service iptables save”

Read more here: Source link