Search code examples
user-agentfirewalliptables

How can I block some special User-agents Via IPTables


I need to block packets from any source that includes some special User agents using IPTables. But I don’t want to manage it via .htaccess or Apache. Is there any way?


Solution

  • You can do it like this:

    iptables -A INPUT -p tcp --dport 80 -m string --algo bm --string "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" -j DROP