User Tools

Site Tools


networking:firewall:block_host

This is an old revision of the document!


Block Traffic From a Particular Host

:!: You can use DROP or REJECT depending on what you want the blocked host to know.

iptables -I INPUT -s 66.184.141.132 -j DROP

Delete the rules:

iptables -D INPUT -s 66.184.141.132 -j DROP

Show the rules:

iptables -L INPUT

One-liner to block evil hosts grep'd from Apache error logs:

for ip in `grep Itau.com.br /var/log/httpd/error_log|egrep -o "client [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"|sort |uniq|cut -f 2 -d " "`; do iptables -I INPUT -s $ip -j DROP; done

Block Hosts by User Agent String

http://en.linuxreviews.org/HOWTO_stop_automated_spam-bots_using_.htaccess

vim .htaccess
# Block bots by User Agent string
SetEnvIfNoCase User-Agent "^Mozilla\/4.0 \(compatible\; MSIE 6.0\; Windows NT 5.1\; SV1\)" bad_bot
# Block empty User Agent string
SetEnvIfNoCase User-Agent ^$ bad_bot
SetEnvIfNoCase User-Agent "^AESOP_com_SpiderMan" bad_bot
SetEnvIfNoCase User-Agent "^Alexibot" bad_bot
SetEnvIfNoCase User-Agent "^Zyborg" bad_bot

<Limit GET POST HEAD>
Order Allow,Deny
Allow from all
Deny from env=bad_bot
</Limit>
service httpd restart
networking/firewall/block_host.1379017002.txt.gz · Last modified: 2013/09/12 14:16 by gcooper