U
U
uaf0x2016-02-29 20:29:57
Apache HTTP Server
uaf0x, 2016-02-29 20:29:57

How to solve with iptables and User-Agent?

Need to kick some bots by user-agent.
I do for example:

iptables -A INPUT -p tcp --dport 80 -m string --algo bm --string "Mozilla/5.0 (compatible; MJ12bot/v1.4.5; http://www.majestic12.co.uk/bot.php?+)" -j DROP

I substitute this user agent in the browser, and it still continues to work, and this bot also hangs out in the Apache logs. How to throw it away?) And another pack with it so that the server is not tormented. And so that they don’t even reach the Apache)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladislav Yandimirkin, 2016-02-29
@vlaad360

Try .htaccess

SetEnvIf User-Agent "Mozilla/5.0 (compatible; MJ12bot/v1.4.5; http://www.majestic12.co.uk/bot.php?+)" BlockBot
Order allow,deny
Deny from env=BlockBot
Allow from all

D
Dimonchik, 2016-02-29
@dimonchik2013

the order is important
if somewhere higher on the 80th port everything is allow , then it’s all the same what I’ll give further DropReject

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question