Sunday, April 20, 2014

Blocking and unblocking an IP using iptables

Iptables is the Linux software firewall.

To block an IP (all ports), as root:

iptables -I INPUT -s ip-address -j DROP

To unblock an IP:

There are two steps. The iptables rule must be deleted by line number, so first you need to determine which rule you want to delete.
iptables -L -n --line-numbers

Next, delete the rule for the IP you want to unblock. This will delete rule number 3:
iptables -D INPUT 3

To clear all firewall rules, use the flush switch
iptables -F

No comments:

Post a Comment