CentOS, CloudLinux™, or Red Hat® Enterprise Linux (RHEL) 6, or Amazon Linux
On a CentOS, CloudLinux, or RHEL 6, or Amazon Linux system, use the iptables
utility to manage your firewall.
- You can block a specific IP address with the
iptables
command. For example, to block192.168.0.0
, run the following command:
iptables -A INPUT -s 192.168.0.0 -j DROP
- You can block a specific port for an IP address. For example, to block port
23
on192.168.0.0
, run the following command:
iptables -A INPUT -s 192.168.0.0 -p tcp –destination-port 23 -j DROP
CentOS 7, CloudLinux 7, or RHEL 7
On a CentOS 7 or CloudLinux 7 system, use the firewalld
utility to manage your firewall.
For example, to block traffic for a single IP address, run the following command, where 192.168.0.0
is the IP address that you wish to block:
firewall-cmd –add-rich-rule=’rule family=”ipv4″ source address=”192.168.0.0″ drop’ –permanent