To block an IP using iptables, use
iptables -A INPUT -s IPADDR -j DROP
Replace IPADDR with IP address you need to block.
To block an IP range
iptables -A INPUT -s IP_IN_CIDR_FORMAT -j DROP
Example, bock IP range 159.138.0.0/16
iptables -A INPUT -s 159.138.0.0/16 -j DROP
Unblock an IP address
To unblock an IP address, first find the rule number, you can do it with the command
iptables --list INPUT -n --line-number | grep IP_ADDR_HERE
Once you find the number of rule to be removed, you can run
iptables --delete INPUT RULE_NUMBER_HERE
Example
See iptables
Leave a Reply