log2command is a PHP script that tracks IPs in log files and executes shell commands per each IP.
log2command is free software, as per the License.
log2command was created as a sort of reverse fail2ban or cheap VPN-firewall: a machine with a closed firewall can be told, by a foreign machine, to accept connections from a specific IP. log2command then keeps track of the webserver log file and watches for inactivity from the user's IP. After an amount of time another command is executed that can remove the user's IP from the firewall, closing down the machine again.
The PHP script is a command-line program that can be run in the background.
The PHP version must be at least 5.3 due to the use of a closure used for parsing log files.
If you're using a Debian base distro, install the following packages:
aptitude install build-essential php5-dev php-pecl
This manual assumes you are familiar with iptables and its chains. The standard command, iptables.sh, creates a new chain during init and then fills and removes it with IP addresses discovered in the log file.
Use PECL to install the inotify extension.
pecl install inotify
It will probably complain that there is no stable version. No problem:
pecl install channel://pecl.php.net/inotify-0.1.4
After installation of the extension is complete, add an ini file in your php conf.d directory that enables the inotify extension (see the last lines of the pecl install).
The example.conf file shows a complete example that can be used as a base for web server <-> iptables communication.
Used in the general way specified in the file a web server can be closed completely to guests and opened up only to logged-in users by another machine that handles logins.
This software is licensed under the GPL v3.