rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

yum -y install fail2ban

sed -i "50s#ignoreip = 127.0.0.1/8#ignoreip = 127.0.0.1/8 113.108.131.85/24#" /etc/fail2ban/jail.conf

sed -i "59s#bantime  = 600#bantime  = 7200#" /etc/fail2ban/jail.conf

sed -i "63s#findtime  = 600#findtime  = 86400#" /etc/fail2ban/jail.conf

sed -i "129s/destemail = root@localhost/destemail = [email protected]/" /etc/fail2ban/jail.conf

sed -i "216a enabled = true" /etc/fail2ban/jail.conf

sed -i "218a action   = iptables[name=SSH, port=ssh, protocol=tcp]" /etc/fail2ban/jail.conf

sed -i '219a sendmail-whois[name=SSH, [email protected], sender=root@localhost, sendername="Fail2Ban"]' /etc/fail2ban/jail.conf

sed -i '220s#^#           #' /etc/fail2ban/jail.conf

sed -i "220a bantime  = 7200" /etc/fail2ban/jail.conf

sed -i "221a findtime  = 86400" /etc/fail2ban/jail.conf

sed -i "222a maxretry = 5" /etc/fail2ban/jail.conf

sed -i "230a enabled = true" /etc/fail2ban/jail.conf

sed -i "232a action  = iptables[name=ssh-ddos, port=ssh,sftp protocol=tcp,udp]" /etc/fail2ban/jail.conf

sed -i '233a sendmail-whois[name=SSH, [email protected], sender=root@localhost, sendername="Fail2Ban"]' /etc/fail2ban/jail.conf

sed -i '234s#^#           #' /etc/fail2ban/jail.conf

sed -i "234a bantime  = 7200" /etc/fail2ban/jail.conf

sed -i "235a findtime  = 86400" /etc/fail2ban/jail.conf

sed -i "236a maxretry = 5" /etc/fail2ban/jail.conf

service fail2ban start