To install Denyhost using yum, ensure that the EPEL repository is installed and enabled (refer to old post albeit an older version).
Installation and configuration
- vi /etc/hosts.allow # whitelist any trusted hosts and/or networks
- yum install denyhosts # install the denyhosts package
- vi /etc/denyhosts.conf # change to suit, the file is well documented
- chkconfig denyhosts --level 2345 on # set runlevels to start daemon on
- service denyhosts start # manually start the daemon
- tail /var/log/denyhosts # confirm daemon started successfully
I wrote a small (single use) script to generate a set of iptables rules from the tcpwrapper hosts.deny file to drop traffic from denied hosts.
for A in `egrep -v '^#' /etc/hosts.deny | tr -d '\t' | tr -d 'ALL:' | grep '[0-9]'`
echo "/sbin/iptables -I -s $A -j DROP"