I hope others will benefit from this cheatsheet as well. Intend to expand it over time as I gather more rules and tips, so bookmarking the post might be a good idea. Last but not least, if you have some useful iptables rules I’ve missed please send them using the comments.
Blocking specific IPs
Code: Select all
iptables -I INPUT -s "207.58.140.12" -j DROP
Code: Select all
iptables -I INPUT -s "207.58.140.0/24" -j DROP
Deleting rules
Just specify the rule after a -D flag. E.g.
Code: Select all
iptables -D INPUT -s "207.58.140.12" -j DROP
Code: Select all
/etc/init.d/iptables save