How to block an IP Address with iptables

banner dedicated


In this tutorial, we will explain you how to block and unblock an IPv4 and IPv6
Address on your Linux Dedicated Server with iptables.


Block an IPv4 Address

iptables -A INPUT -s IP_ADDRESS -j DROP


Block an IPv6 Address

ip6tables -A INPUT -s IP_ADDRESS -j DROP


Block an IPv4 Address on a specific port

iptables -A INPUT -s IP_ADDRESS --dport 80 -j DROP


Block an IPv6 Address on a specific port

ip6tables -A INPUT -s IP_ADDRESS --dport 80 -j DROP


Unblock an IPv4 Address

iptables -D INPUT -s IP_ADDRESS -j DROP


Unblock an IPv6 Address

ip6tables -D INPUT -s IP_ADDRESS -j DROP


Remember to save your Firewall rules

service iptables save
service ip6tables save


banner dedicated


Colo-Serv Communications has written 32 articles

Premium Dedicated Hosting Services