{"id":2082,"date":"2013-09-28T21:36:32","date_gmt":"2013-09-29T02:36:32","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=2082"},"modified":"2022-06-03T03:52:17","modified_gmt":"2022-06-03T08:52:17","slug":"install-fail2ban-on-centos","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/","title":{"rendered":"Install Fail2ban on CentOS"},"content":{"rendered":"
<\/div>

\"Install<\/p>\n

In this article we will explain how to install fail2ban on CentOS<\/a>. Fail2ban is a free and open source framework developed in Python. It is an excellent and very helpful tool for stopping the endless brute force attacks on your services and preventing intrusions into your system. Fail2ban scans the log files on your server for repeated password failures and bans the offending IP addresses. Installing Fail2Ban on CentOs is an easy task if you carefully follow the steps bellow.<\/p>\n

<\/p>\n

Fail2ban is not available by default under CentOS, so first we need to enable the third party EPEL repository.<\/p>\n

CentOS 6 32 bit:<\/p>\n

# rpm -Uvh http:\/\/mirror.pnl.gov\/epel\/\/6\/i386\/epel-release-6-8.noarch.rpm<\/pre>\n

CentOS 6 64 bit:<\/p>\n

# rpm -Uvh http:\/\/mirror.us.leaseweb.net\/epel\/6\/x86_64\/epel-release-6-8.noarch.rpm<\/pre>\n

You can verify that the EPEL repository is enabled by executing:<\/p>\n

# yum repolist\r\nRepository base is listed more than once in the configuration\r\nrepo id                                   repo name                                                              status\r\nbase                                      CentOS 6 - i686 - Base                                                 4,787+15\r\nepel                                      Extra Packages for Enterprise Linux 6 - i386                              7,959\r\nextras                                    CentOS-6 - Extras                                                            12\r\nupdates                                   CentOS-6 - Updates                                                       844+50\r\nupdates-released                          CentOS 6 - i686 - Released Updates                                       844+50\r\nrepolist: 14,446<\/pre>\n

Install fail2ban using the standard way for installing rpm packages:<\/p>\n

# yum install fail2ban<\/pre>\n

Set fail2ban to start automatically on boot:<\/p>\n

# chkconfig --add fail2ban\r\n# chkconfig fail2ban on<\/pre>\n

With this, the installation is done. Now you need to tweak fail2ban’s settings according to your needs by editing the default configuration file ‘jail.conf’ located in the ‘\/etc\/fail2ban’ directory on your server. In this file you can set which services you want to be monitored, the number of failed login attempts before the IP address is banned, the ban time of the IP address, etc…<\/p>\n

Open the \/etc\/fail2ban\/jail.conf file and add your own IP address and all your trusted IP addresses into the ignoreip<\/strong> line. Each IP address\/network can be separated with a space. For example:<\/p>\n

# \"ignoreip\" can be an IP address, a CIDR mask or a DNS host. Fail2ban will not\r\n# ban a host which matches an address in this list. Several addresses can be\r\n# defined using space separator.\r\nignoreip = 127.0.0.1 1.2.3.4 123.123.123.0\/24<\/pre>\n

The next thing you will notice is bantime<\/strong>. This number shows how long the IP address will be blocked for by the server in seconds. The default number is 600 seconds and you can decrease or increase this number according to your needs.<\/p>\n

maxretry<\/strong> is the number of failed login attempts before fail2ban bans an IP address.<\/p>\n

findtime<\/strong> is a time frame in which a host has to log in. This means that if a host fails to log in to some of your services in this time frame it will be banned. The default findtime is 600 seconds.<\/p>\n

This file also contains default sections with basic rules about a few services that can be monitored.<\/p>\n

Once you have made the desired changes in the default jail.conf file you need to restart fail2ban:<\/p>\n

# service fail2ban restart<\/pre>\n

You can check the iptables rules added by fail2ban by executing:<\/p>\n

# iptables -L<\/pre>\n

Of course, if you are one of our Linux VPS Hosting<\/a> customers, you don\u2019t have to Install Fail2ban on CentOS, simply ask our admins, sit back and relax. Our admins will install Fail2Ban for you immediately.<\/p>\n

PS.<\/strong><\/span> If you liked this post, on how to\u00a0Install Fail2ban on CentOS,\u00a0 please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks<\/p>\n

 <\/p>\n","protected":false},"excerpt":{"rendered":"

In this article we will explain how to install fail2ban on CentOS. Fail2ban is a free and open source framework … <\/p>\n

Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":26527,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1699,1701,1703,13],"tags":[124,280,281,177,1152,65],"yoast_head":"\nInstall Fail2ban on CentOS - RoseHosting<\/title>\n<meta name=\"description\" content=\"Install Fail2ban on CentOS - RoseHosting\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Install Fail2ban on CentOS - RoseHosting\" \/>\n<meta property=\"og:description\" content=\"Install Fail2ban on CentOS - RoseHosting\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/\" \/>\n<meta property=\"og:site_name\" content=\"RoseHosting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/RoseHosting\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/rosehosting.helpdesk\" \/>\n<meta property=\"article:published_time\" content=\"2013-09-29T02:36:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-06-03T08:52:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2013\/09\/Install-Fail2ban-on-CentOS.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jeff Wilson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:site\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeff Wilson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/\"},\"author\":{\"name\":\"Jeff Wilson\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713\"},\"headline\":\"Install Fail2ban on CentOS\",\"datePublished\":\"2013-09-29T02:36:32+00:00\",\"dateModified\":\"2022-06-03T08:52:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/\"},\"wordCount\":472,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2013\/09\/Install-Fail2ban-on-CentOS.jpg\",\"keywords\":[\"centos vps\",\"fail2ban\",\"iptables\",\"linux vps\",\"rosehosting\",\"security\"],\"articleSection\":[\"CentOS\",\"Networking and Domains\",\"Security\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/\",\"name\":\"Install Fail2ban on CentOS - RoseHosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2013\/09\/Install-Fail2ban-on-CentOS.jpg\",\"datePublished\":\"2013-09-29T02:36:32+00:00\",\"dateModified\":\"2022-06-03T08:52:17+00:00\",\"description\":\"Install Fail2ban on CentOS - RoseHosting\",\"breadcrumb\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#primaryimage\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2013\/09\/Install-Fail2ban-on-CentOS.jpg\",\"contentUrl\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2013\/09\/Install-Fail2ban-on-CentOS.jpg\",\"width\":1200,\"height\":600,\"caption\":\"Install Fail2ban on CentOS\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.rosehosting.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Install Fail2ban on CentOS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#website\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/\",\"name\":\"RoseHosting\",\"description\":\"Premium Linux Tutorials Since 2001\",\"publisher\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#organization\",\"name\":\"RoseHosting\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png\",\"contentUrl\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png\",\"width\":192,\"height\":192,\"caption\":\"RoseHosting\"},\"image\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/RoseHosting\",\"https:\/\/x.com\/rosehosting\",\"https:\/\/www.linkedin.com\/in\/rosehosting\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713\",\"name\":\"Jeff Wilson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/09271207587f897ab46faaed9b355252?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/09271207587f897ab46faaed9b355252?s=96&r=g\",\"caption\":\"Jeff Wilson\"},\"description\":\"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.\",\"sameAs\":[\"https:\/\/www.rosehosting.com\",\"https:\/\/www.facebook.com\/rosehosting.helpdesk\"],\"url\":\"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Install Fail2ban on CentOS - RoseHosting","description":"Install Fail2ban on CentOS - RoseHosting","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/","og_locale":"en_US","og_type":"article","og_title":"Install Fail2ban on CentOS - RoseHosting","og_description":"Install Fail2ban on CentOS - RoseHosting","og_url":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/","og_site_name":"RoseHosting","article_publisher":"https:\/\/www.facebook.com\/RoseHosting","article_author":"https:\/\/www.facebook.com\/rosehosting.helpdesk","article_published_time":"2013-09-29T02:36:32+00:00","article_modified_time":"2022-06-03T08:52:17+00:00","og_image":[{"width":1200,"height":600,"url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2013\/09\/Install-Fail2ban-on-CentOS.jpg","type":"image\/jpeg"}],"author":"Jeff Wilson","twitter_card":"summary_large_image","twitter_creator":"@rosehosting","twitter_site":"@rosehosting","twitter_misc":{"Written by":"Jeff Wilson","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#article","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/"},"author":{"name":"Jeff Wilson","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713"},"headline":"Install Fail2ban on CentOS","datePublished":"2013-09-29T02:36:32+00:00","dateModified":"2022-06-03T08:52:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/"},"wordCount":472,"commentCount":0,"publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2013\/09\/Install-Fail2ban-on-CentOS.jpg","keywords":["centos vps","fail2ban","iptables","linux vps","rosehosting","security"],"articleSection":["CentOS","Networking and Domains","Security","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/","url":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/","name":"Install Fail2ban on CentOS - RoseHosting","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#primaryimage"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2013\/09\/Install-Fail2ban-on-CentOS.jpg","datePublished":"2013-09-29T02:36:32+00:00","dateModified":"2022-06-03T08:52:17+00:00","description":"Install Fail2ban on CentOS - RoseHosting","breadcrumb":{"@id":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#primaryimage","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2013\/09\/Install-Fail2ban-on-CentOS.jpg","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2013\/09\/Install-Fail2ban-on-CentOS.jpg","width":1200,"height":600,"caption":"Install Fail2ban on CentOS"},{"@type":"BreadcrumbList","@id":"https:\/\/www.rosehosting.com\/blog\/install-fail2ban-on-centos\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.rosehosting.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Install Fail2ban on CentOS"}]},{"@type":"WebSite","@id":"https:\/\/www.rosehosting.com\/blog\/#website","url":"https:\/\/www.rosehosting.com\/blog\/","name":"RoseHosting","description":"Premium Linux Tutorials Since 2001","publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.rosehosting.com\/blog\/#organization","name":"RoseHosting","url":"https:\/\/www.rosehosting.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","width":192,"height":192,"caption":"RoseHosting"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/RoseHosting","https:\/\/x.com\/rosehosting","https:\/\/www.linkedin.com\/in\/rosehosting\/"]},{"@type":"Person","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713","name":"Jeff Wilson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/09271207587f897ab46faaed9b355252?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/09271207587f897ab46faaed9b355252?s=96&r=g","caption":"Jeff Wilson"},"description":"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.","sameAs":["https:\/\/www.rosehosting.com","https:\/\/www.facebook.com\/rosehosting.helpdesk"],"url":"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/2082"}],"collection":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/comments?post=2082"}],"version-history":[{"count":1,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/2082\/revisions"}],"predecessor-version":[{"id":42283,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/2082\/revisions\/42283"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media\/26527"}],"wp:attachment":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media?parent=2082"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/categories?post=2082"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/tags?post=2082"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}