Blacklisting incoming sites using iptables

Use this command to add an ip address to be blocked by iptables:

<code>
iptables -I INPUT -s x.x.x.x -j DROP
iptables -I INPUT -s x.x.x.x -j LOG
</code>

This example inserts a rule at the top of the table to block all incoming requests from ip x.x.x.x, and then inserts a second rule at the top to first log any connection attempts from this address (before they are blocked).

To see what rules are currently configured, use: iptables -L

For more info, see this entry in the O’Reily Linux Hacks book.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.