One of our servers is being hit daily by a large number of spam bots. They're not able to post any spam, but they still try and end up slowing down the server for real users.
To counter this, I have a PHP script running on the site which detects their IP addresses. However, I want this script to automatically add these IP addresses to the firewall (rather than me having to do that manually). Running something like this:
iptables -I INPUT -j DROP -s 22.214.171.124
However, it looks like
iptables commands can only be run as root. Any way around this?
I guess I could have the commands added to a file which
root runs via cron, but don't really want any delay between the php script making the decision to ban an IP and the ban being added.