{"id":3604,"date":"2016-03-26T07:44:09","date_gmt":"2016-03-26T07:44:09","guid":{"rendered":"https:\/\/cpanelplesk.com\/wp62\/?p=3604"},"modified":"2021-02-06T05:59:04","modified_gmt":"2021-02-06T05:59:04","slug":"install-fail2ban-centos","status":"publish","type":"post","link":"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/","title":{"rendered":"How to install FAIL2BAN on CentOS"},"content":{"rendered":"<p>This article will guide you how to install Fail2Ban on CentOS so that you can protect your server from Brute force attacks, previously we have discuss about some <a href=\"https:\/\/cpanelplesk.com\/wp62\/basic-security-steps-for-centos-web-panel\/\">basic configs for CentOS<\/a>. But sometimes that is not enough as brute force attacks may occur occasionally.<\/p>\n<p>Fail2ban scan log files for selected entries then bans IPs that show the malicious signs like too many password failures, seeking for exploits, etc. using firewall.<!--more--><\/p>\n<h2>INSTALLATION:<\/h2>\n<p>Login to your server as a root user.<\/p>\n<p>Note: Fail2ban is not available by default in CentOS,so you have to firstly add EPEL repo to install directly it via yum.<\/p>\n<p><strong>CentOS 6:<\/strong><\/p>\n<div class=\"command-sh\">\n<pre class=\"lang:default decode:true \">rpm -Uvh http:\/\/dl.fedoraproject.org\/pub\/epel\/6\/x86_64\/epel-release-6-8.noarch.rpm<\/pre>\n<\/div>\n<p><strong>CentOS 7:<\/strong><\/p>\n<div class=\"command-sh\">\n<pre class=\"lang:default decode:true \">rpm -Uvh http:\/\/dl.fedoraproject.org\/pub\/epel\/7\/x86_64\/e\/epel-release-7-1.noarch.rpm<\/pre>\n<\/div>\n<p>Now install it using YUM:<\/p>\n<div class=\"command-sh\">\n<pre class=\"lang:default decode:true \">yum install fail2ban \u2013y<\/pre>\n<\/div>\n<h2>Fail2ban Configuration:<\/h2>\n<p>Once Fail2ban is installed on your VPS, next you have to do some basic Fail2Ban configuration.<\/p>\n<p>The default Fail2Ban configuration file is\u00a0\/etc\/fail2ban\/jail.conf, however it is not recommended to modify it directly.<\/p>\n<p>Firstly make a local copy of default configuration file.<\/p>\n<div class=\"cpanel-files\"><\/div>\n<pre class=\"lang:default decode:true \">cp \/etc\/fail2ban\/jail.conf \/etc\/fail2ban\/jail.local<\/pre>\n<p>Now edit\u00a0<strong>jail.local<\/strong>\u00a0file\u00a0you copied by using your favorite editor like Nano.<\/p>\n<div class=\"cpanel-files\"><\/div>\n<pre class=\"lang:default decode:true \">nano \/etc\/fail2ban\/jail.local<\/pre>\n<p>Pay attention to the global options in\u00a0<strong>[DEFAULT]<\/strong>\u00a0section.It covers the basic rules that Fail2Ban will follow.<\/p>\n<p>Scroll down the page for all available configurations. You can edit as suits your need including: i<strong>gnoreip, bantime, findtime, and maxretry<\/strong>. You can read what each line means in the explanation available there.<\/p>\n<p>If you wish to tweak the existing filters or add new filters, you can find them in the\/etc\/fail2ban\/filter.d\u00a0directory.<\/p>\n<h2>Tweaking Fail2Ban Filters<\/h2>\n<p>If you want to tweak the existing filters or add new filters, you can find them in the<strong>\/etc\/fail2ban\/filter.d<\/strong>\u00a0directory.<\/p>\n<p>For example, to modify Fail2Ban filter for\u00a0OpenSSH, edit the following file:<\/p>\n<div class=\"cpanel-files\"><\/div>\n<pre class=\"lang:default decode:true \">nano \/etc\/fail2ban\/filter.d\/sshd.conf<\/pre>\n<p>Now restart Fail2ban so the new configuration can take effect.<\/p>\n<p><strong>CentOS 7:<\/strong><\/p>\n<div class=\"command-sh\">\n<pre class=\"lang:default decode:true \">systemctl restart fail2ban.service<\/pre>\n<\/div>\n<p><strong>CentOS 6:<\/strong><\/p>\n<div class=\"command-sh\">\n<pre class=\"lang:default decode:true \">Service fail2ban restart<\/pre>\n<\/div>\n<h2>Test Fail2ban:<\/h2>\n<p>To test Fail2Ban and to see the rules that Fail2Ban puts in effect, look at iptables:<\/p>\n<div class=\"command-sh\">\n<pre class=\"lang:default decode:true \">iptables \u2013L<\/pre>\n<\/div>\n<h2>Manually un-ban the IP from Fail2Ban:<\/h2>\n<p>Use the flowing command to manually unban IP address, banned by Fail2Ban:<\/p>\n<div class=\"command-sh\">\n<pre class=\"lang:default decode:true \">fail2ban-client set JAIL unbanip IP<\/pre>\n<\/div>\n<p>That\u2019s it. Enjoy..<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article will guide you how to install Fail2Ban on CentOS so that you can protect your server from Brute force attacks, previously we have discuss about some basic configs for CentOS. But sometimes that is not enough as brute force attacks may occur occasionally. Fail2ban scan log files for selected entries then bans IPs [&#8230;]<\/p>\n<p><a class=\"understrap-read-more-link\" href=\"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/\">Continue Reading&#8230;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,14],"tags":[],"class_list":["post-3604","post","type-post","status-publish","format-standard","hentry","category-cpanel","category-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to install FAIL2BAN on CentOS - cPanel Plesk<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to install FAIL2BAN on CentOS - cPanel Plesk\" \/>\n<meta name=\"twitter:description\" content=\"This article will guide you how to install Fail2Ban on CentOS so that you can protect your server from Brute force attacks, previously we have discuss about some basic configs for CentOS. But sometimes that is not enough as brute force attacks may occur occasionally. Fail2ban scan log files for selected entries then bans IPs [...]Continue Reading...\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Seemab Saleem\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/\"},\"author\":{\"name\":\"Seemab Saleem\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648\"},\"headline\":\"How to install FAIL2BAN on CentOS\",\"datePublished\":\"2016-03-26T07:44:09+00:00\",\"dateModified\":\"2021-02-06T05:59:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/\"},\"wordCount\":360,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\"},\"articleSection\":[\"Cpanel\",\"Linux\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/\",\"name\":\"How to install FAIL2BAN on CentOS - cPanel Plesk\",\"isPartOf\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#website\"},\"datePublished\":\"2016-03-26T07:44:09+00:00\",\"dateModified\":\"2021-02-06T05:59:04+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cpanelplesk.com\/wp62\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to install FAIL2BAN on CentOS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#website\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/\",\"name\":\"cPanel Plesk\",\"description\":\"Blog on famous hosting control panels\",\"publisher\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cpanelplesk.com\/wp62\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\",\"name\":\"Farooq Omer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png\",\"contentUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png\",\"width\":300,\"height\":44,\"caption\":\"Farooq Omer\"},\"logo\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648\",\"name\":\"Seemab Saleem\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g\",\"caption\":\"Seemab Saleem\"},\"description\":\"Linux Server Administrator, Web Hosting engineer. I'm dealing with Linux servers since 2014. I started this blog to share the work i love with the world . let me know if you need any assistance. Thanks!!\",\"sameAs\":[\"https:\/\/cpanelplesk.com\/wp62\"],\"url\":\"https:\/\/cpanelplesk.com\/wp62\/author\/cmb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to install FAIL2BAN on CentOS - cPanel Plesk","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:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/","twitter_card":"summary_large_image","twitter_title":"How to install FAIL2BAN on CentOS - cPanel Plesk","twitter_description":"This article will guide you how to install Fail2Ban on CentOS so that you can protect your server from Brute force attacks, previously we have discuss about some basic configs for CentOS. But sometimes that is not enough as brute force attacks may occur occasionally. Fail2ban scan log files for selected entries then bans IPs [...]Continue Reading...","twitter_misc":{"Written by":"Seemab Saleem","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/#article","isPartOf":{"@id":"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/"},"author":{"name":"Seemab Saleem","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648"},"headline":"How to install FAIL2BAN on CentOS","datePublished":"2016-03-26T07:44:09+00:00","dateModified":"2021-02-06T05:59:04+00:00","mainEntityOfPage":{"@id":"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/"},"wordCount":360,"commentCount":0,"publisher":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13"},"articleSection":["Cpanel","Linux"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/","url":"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/","name":"How to install FAIL2BAN on CentOS - cPanel Plesk","isPartOf":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#website"},"datePublished":"2016-03-26T07:44:09+00:00","dateModified":"2021-02-06T05:59:04+00:00","breadcrumb":{"@id":"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cpanelplesk.com\/wp62\/install-fail2ban-centos\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cpanelplesk.com\/wp62\/"},{"@type":"ListItem","position":2,"name":"How to install FAIL2BAN on CentOS"}]},{"@type":"WebSite","@id":"https:\/\/cpanelplesk.com\/wp62\/#website","url":"https:\/\/cpanelplesk.com\/wp62\/","name":"cPanel Plesk","description":"Blog on famous hosting control panels","publisher":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cpanelplesk.com\/wp62\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13","name":"Farooq Omer","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/","url":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png","contentUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png","width":300,"height":44,"caption":"Farooq Omer"},"logo":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648","name":"Seemab Saleem","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g","caption":"Seemab Saleem"},"description":"Linux Server Administrator, Web Hosting engineer. I'm dealing with Linux servers since 2014. I started this blog to share the work i love with the world . let me know if you need any assistance. Thanks!!","sameAs":["https:\/\/cpanelplesk.com\/wp62"],"url":"https:\/\/cpanelplesk.com\/wp62\/author\/cmb\/"}]}},"_links":{"self":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts\/3604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/comments?post=3604"}],"version-history":[{"count":0,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts\/3604\/revisions"}],"wp:attachment":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/media?parent=3604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/categories?post=3604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/tags?post=3604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}