Fail2ban<\/strong><\/span><\/a>\u00a0is a program that monitors login activity on your server and blocks offending IP addresses. By default, it will block IP addresses for 10 minutes before unblocking them. Fail2ban has filters to monitor Apache, Courier, SSH, and other programs for suspicious activity.<\/p>\nThis guide assumes that you are running a modern version of Ubuntu x64.<\/p>\n
Installing<\/h3>\n
Run the following commands to install Fail2ban.<\/p>\n
sudo apt-get update\r\nsudo apt-get install fail2ban\r\n<\/code><\/pre>\nConfiguring<\/h3>\n
The the default configuration file is located as follows.<\/p>\n
\/etc\/fail2ban\/jail.conf\r\n<\/code><\/pre>\nTo avoid possible conflict, you should make a copy of it. For this example, we will call it\u00a0jail.local<\/code>.<\/p>\nsudo cp \/etc\/fail2ban\/jail.conf \/etc\/fail2ban\/jail.local\r\n<\/code><\/pre>\nNow that we have a backup, let’s begin editing. Open the\u00a0jail.local<\/code>\u00a0file in your favorite text editor.<\/p>\nsudo vi \/etc\/fail2ban\/jail.local\r\n<\/code><\/pre>\nYou may use my config example below. It is configured for SSH. There are some settings that you may want to tweak, such as:<\/p>\n
\n- Adding email notifications for when someone is trying to access the server.<\/li>\n
- The length of the ban.<\/li>\n
- The max number of retries before a ban is executed.<\/li>\n
- Include your static IP in “ignoreip” (if you have one).<\/li>\n<\/ul>\n
Example config<\/h4>\n[DEFAULT]\r\nignoreip = 127.0.0.1\/8\r\nbantime = 1800\r\nmaxretry = 4\r\n\r\n[ssh-route]\r\nmaxretry = 3\r\naction = iptables[name=SSH, port=ssh, protocol=tcp]\r\n sendmail-whois[name=SSH, dest=root, sender=fail2ban@your-domain.com]\r\n<\/code><\/pre>\nOnce you have made any configuration changes, restart Fail2ban and you’re good to go.<\/p>\n
sudo service fail2ban restart<\/code><\/pre>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[245,247],"manual_kb_tag":[505],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/3030"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=3030"}],"version-history":[{"count":1,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/3030\/revisions"}],"predecessor-version":[{"id":3031,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/3030\/revisions\/3031"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=3030"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=3030"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=3030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}