<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
		<id>http://wiki.diouxx.be/index.php?action=history&amp;feed=atom&amp;title=Fail2ban</id>
		<title>Fail2ban - Historique des versions</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.diouxx.be/index.php?action=history&amp;feed=atom&amp;title=Fail2ban"/>
		<link rel="alternate" type="text/html" href="http://wiki.diouxx.be/index.php?title=Fail2ban&amp;action=history"/>
		<updated>2026-04-16T16:20:53Z</updated>
		<subtitle>Historique des versions pour cette page sur le wiki</subtitle>
		<generator>MediaWiki 1.30.2</generator>

	<entry>
		<id>http://wiki.diouxx.be/index.php?title=Fail2ban&amp;diff=110&amp;oldid=prev</id>
		<title>Ddevleeschauwer le 31 décembre 2014 à 10:04</title>
		<link rel="alternate" type="text/html" href="http://wiki.diouxx.be/index.php?title=Fail2ban&amp;diff=110&amp;oldid=prev"/>
				<updated>2014-12-31T10:04:24Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;fr&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Version précédente&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Version du 31 décembre 2014 à 10:04&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l205&quot; &gt;Ligne 205 :&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Ligne 205 :&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;bantime = 900&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;bantime = 900&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== Ban persistant ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Vous pouvez faire des bans persistants par la création d'une liste noire et le chargement de cette liste noir lorsque fail2ban est redémarré automatiquement. D'abord, vous devez créer un fichier pour stocker les adresses IP sur liste noire.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{ Console root | sudo touch /etc/fail2ban/ip.blacklist }}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Ensuite, vous pouvez soit faire une copie ou modifier le fichier {{ File | 1=/etc/fail2ban/action.d/iptables-multiport.conf }}.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Dans le fichier de configuration d'action il y a plusieurs directives différentes, nous voulons nous concentrer sur deux, la directive '''actionstart''' et '''actionban'''. Premièrement, lorsque fail2ban interdit une adresse IP, nous voulons non seulement l'interdire, mais nous voulons aussi ajouter l'adresse IP dans le fichier {{ File | ip.blacklist}}.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;actionban = iptables -I fail2ban-&amp;lt;name&amp;gt; 1 -s &amp;lt;ip&amp;gt; -j &amp;lt;blocktype&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; echo &amp;lt;ip&amp;gt; &amp;gt;&amp;gt; /etc/fail2ban/ip.blacklist&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Ensuite, nous voulons être sûrs que la règle iptables est ajouté lorsque fail2ban démarre, donc nous ajoutons les lignes de code à la directive '''actionstart''' suivantes:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;actionstart = iptables -N fail2ban-&amp;lt;name&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; iptables -A fail2ban-&amp;lt;name&amp;gt; -j RETURN&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; iptables -I &amp;lt;chain&amp;gt; -p &amp;lt;protocol&amp;gt; -m multiport --dports &amp;lt;port&amp;gt; -j fail2ban-&amp;lt;name&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; cat /etc/fail2ban/ip.blacklist | while read IP; do iptables -I fail2ban-&amp;lt;name&amp;gt; 1 -s $IP -j DROP; done&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Maintenant, dés que fail2ban va démarrer/redémarrer, il va automatiquement bannir toutes les IP se trouvant dans le fichier {{ File | 1=/etc/fail2ban/ip.blacklist }}.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Liens externes ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Liens externes ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l212&quot; &gt;Ligne 212 :&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Ligne 238 :&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;http://www.commentcamarche.net/faq/18225-utiliser-fail2ban-pour-proteger-votre-application-web &amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;http://www.commentcamarche.net/faq/18225-utiliser-fail2ban-pour-proteger-votre-application-web &amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;http://www.fail2ban.org/wiki/index.php/MANUAL_0_8#Testing &amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;http://www.fail2ban.org/wiki/index.php/MANUAL_0_8#Testing &amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;http://zach.seifts.us/posts/2013/07/14/how-make-fail2ban-bans-persistent&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Catégorie:Système]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Catégorie:Système]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wikidb:diff:version:1.11a:oldid:22:newid:110 --&gt;
&lt;/table&gt;</summary>
		<author><name>Ddevleeschauwer</name></author>	</entry>

	<entry>
		<id>http://wiki.diouxx.be/index.php?title=Fail2ban&amp;diff=22&amp;oldid=prev</id>
		<title>Ddevleeschauwer : Page créée avec « == Comment marche Fail2Ban ? ==  Développé en langage Python, Fail2Ban est un logiciel libre permettant d'analyser des fichiers de logs et de déclencher des actions si ... »</title>
		<link rel="alternate" type="text/html" href="http://wiki.diouxx.be/index.php?title=Fail2ban&amp;diff=22&amp;oldid=prev"/>
				<updated>2013-03-30T11:58:00Z</updated>
		
		<summary type="html">&lt;p&gt;Page créée avec « == Comment marche Fail2Ban ? ==  Développé en langage Python, Fail2Ban est un logiciel libre permettant d&amp;#039;analyser des fichiers de logs et de déclencher des actions si ... »&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Comment marche Fail2Ban ? ==&lt;br /&gt;
&lt;br /&gt;
Développé en langage Python, Fail2Ban est un logiciel libre permettant d'analyser des fichiers de logs et de déclencher des actions si certaines choses suspectes sont détectées. La grande force de Fail2Ban est sa grande modularité que cela soit au niveau des mécanismes de détections basées sur les expressions régulières ou sur les actions à mener qui peuvent aller de l'expédition d'un mail à la mise en place de règles de Firewall.&lt;br /&gt;
&lt;br /&gt;
Fail2Ban se base sur un système de prisons (jails) que l'on peut définir, activer ou désactiver dans un simple fichier de configuration (/etc/fail2ban/jail.conf).&lt;br /&gt;
&lt;br /&gt;
Une prison (jail) est composée, entre autres, des éléments suivants:&lt;br /&gt;
&lt;br /&gt;
* Nom du fichier de log à analyser.&lt;br /&gt;
* Filtre à appliquer sur ce fichier de log (la liste des filtres disponibles se trouve dans le répertoire /etc/fail2ban/filter.d). Il est bien sûr possible de créer ses propres filtres.&lt;br /&gt;
* Paramètres permettant de définir si une action doit être déclenchée quand le filtre correspond (&amp;quot;match&amp;quot;): Nombre de &amp;quot;matchs&amp;quot; (maxretry), intervalle de temps correspondant (findtime)...&lt;br /&gt;
* Action à mener si nécessaire. La liste des actions se trouve dans le répertoire /etc/fail2ban/action.d. Il est également possible de créer ses propres actions.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
On commence par installer Fail2Ban sur son système. Il se trouve dans la grande majorité des distributions GNU/Linux et BSD. par exemple pour l'installer sur une machine Debian 6, il suffit de saisir la commande suivante (en root ou bien précédée d'un sudo):&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ Console root | apt-get install fail2ban }}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Protection contre les attaques &amp;quot;brute force&amp;quot; SSH ===&lt;br /&gt;
&lt;br /&gt;
Un exemple étant toujours plus parlant, nous allons configurer notre Fail2Ban pour bloquer automatiquement les adresses IP des machines essayant des attaques de type &amp;quot;brute force&amp;quot; sur notre port SSH (cette attaque est à la portée de n'importe quel &amp;quot;neuneu&amp;quot;. On trouve de très bon tutoriaux sur le sujet sur le net).&lt;br /&gt;
&lt;br /&gt;
Si une machine cliente échoue 2 fois de suite lors de la saisie du couple login/password sur le serveur SSH alors on bloque l'accès au port TCP/SSH pendant 15 minutes. &lt;br /&gt;
On analyse pour cela le fichier de log {{ File | /var/log/auth.log }} en lui appliquant le filtre {{ File | /etc/fail2ban/filter.d/sshd.conf }} puis, si nécessaire, l'action {{ File | /etc/fail2ban/action.d/iptables.conf}}&lt;br /&gt;
La définition de cette prison (jail) est à faire dans le fichier {{ File | /etc/fail2ban/jail.conf }}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# SSH&lt;br /&gt;
# 2 retry ? &amp;gt; Ban for 15 minutes&lt;br /&gt;
[ssh]&lt;br /&gt;
enabled = true&lt;br /&gt;
port = ssh&lt;br /&gt;
filter = sshd&lt;br /&gt;
action = iptables[name=SSH, port=ssh, protocol=tcp]&lt;br /&gt;
logpath = /var/log/auth.log&lt;br /&gt;
maxretry = 2&lt;br /&gt;
bantime = 900&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Un fois le filtre activé en relançant Fail2Ban avec la commande (en root):&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ Console root | service fail2ban restart }}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut rapidement voir son efficacité en regardant le fichier de log {{ File | /var/log/fail2ban.log }}&lt;br /&gt;
&lt;br /&gt;
=== Protection contre les attaques DOS (HTTP/GET) ===&lt;br /&gt;
&lt;br /&gt;
Dans ce deuxième exemple nous allons voir comment lutter efficacement contre les attaques de type DOS ciblant vos serveurs Web. Ces attaques se caractérisent par un nombre inhabituel de requêtes HTTP venant d'un même client (du moins d'une même adresse IP source).&lt;br /&gt;
&lt;br /&gt;
Le plus difficile est de trouver les bons paramètres correspondants à un comportement &amp;quot;inhabituel&amp;quot;. Dans l'exemple suivant, je considère comme &amp;quot;inhabituel&amp;quot; le fait qu'un client effectue plus de 360 requêtes en 2 minutes (soit une moyenne de supérieurement à 3 req/sec) sur mon serveur Web. Dans ce cas, je bloque l'accès au port HTTP pendant une durée de 10 minutes.&lt;br /&gt;
&lt;br /&gt;
La prison (jail) correspondante est la suivante à ajouter dans votre fichier {{ File | /etc/fail2ban/jail.conf }}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Protect against DOS attack&lt;br /&gt;
# 360 requests in 2 min &amp;gt; Ban for 10 minutes&lt;br /&gt;
[http-get-dos]&lt;br /&gt;
enabled = true&lt;br /&gt;
port = http,https&lt;br /&gt;
filter = http-get-dos&lt;br /&gt;
logpath = /var/log/apache2/acces.log&lt;br /&gt;
maxretry = 360&lt;br /&gt;
findtime = 120&lt;br /&gt;
action = iptables[name=HTTP, port=http, protocol=tcp]&lt;br /&gt;
bantime = 600&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il est tout a fait possible d'utiliser plusieurs fichiers de logs. Par exemple, si on utilise des virtuals Host et que ceux-ci ont des fichiers logs bien distincts.&lt;br /&gt;
Pour réaliser cela, il suffit de renseigner les différents fichiers pour l avariable logpath :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
logpath = /var/log/apache2/acces.log&lt;br /&gt;
          /var/log/apache2/access-crm.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Le filtre http-get-dos n'est pas fourni par défaut. Il faut donc éditer le fichier {{ File | /etc/fail2ban/filter.d/http-get-dos.conf}} avec le contenu suivant:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Fail2Ban configuration file&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Author: http://www.go2linux.org&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
[Definition]&lt;br /&gt;
&lt;br /&gt;
# Option: failregex&lt;br /&gt;
&lt;br /&gt;
# Note: This regex will match any GET entry in your logs, so basically all valid and not valid entries are a match.&lt;br /&gt;
&lt;br /&gt;
# You should set up in the jail.conf file, the maxretry and findtime carefully in order to avoid false positives.&lt;br /&gt;
&lt;br /&gt;
failregex = ^&amp;lt;HOST&amp;gt;.*&amp;quot;GET&lt;br /&gt;
&lt;br /&gt;
# Option: ignoreregex&lt;br /&gt;
&lt;br /&gt;
# Notes.: regex to ignore. If this regex matches, the line is ignored.&lt;br /&gt;
&lt;br /&gt;
# Values: TEXT&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
ignoreregex =&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Un fois le filtre activé:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ Console root | service fail2ban restart }}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Requêtes w00tw00t ===&lt;br /&gt;
Voici un exemple, pour bannir les désormais célèbres requêtes DFind w00tw00t. Dans le fichier {{ File | /etc/fail2ban/jail.conf}} on ajoute :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[apache-w00tw00t]&lt;br /&gt;
enabled = true&lt;br /&gt;
filter = apache-w00tw00t&lt;br /&gt;
action = iptables[name=Apache-w00tw00t,port=80,protocol=tcp]&lt;br /&gt;
logpath = /var/log/apache2/access*.log&lt;br /&gt;
maxretry = 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On notera que contrairement aux autres règles, celle-ci s'attaque au fichier de log des accès (/var/log/apache2/access*.log).&lt;br /&gt;
&lt;br /&gt;
Voici le fichier de règles {{ File | /etc/fail2ban/filter.d/apache-w00tw00t.conf }}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Definition]&lt;br /&gt;
&lt;br /&gt;
failregex = ^&amp;lt;HOST&amp;gt; -.*&amp;quot;GET \/w00tw00t\.at\.ISC\.SANS\.DFind\:\).*&amp;quot;.*&lt;br /&gt;
&lt;br /&gt;
ignoreregex =&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Un fois le filtre activé:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ Console root | service fail2ban restart }}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lister les IP bannies ==&lt;br /&gt;
&lt;br /&gt;
Listez les ip bannies avec la commande:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ Console root | iptables -L }}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Vous obtiendrez quelque chose du genre:&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
...&lt;br /&gt;
Chain fail2ban-ssh (1 references)&lt;br /&gt;
target     prot opt source               destination&lt;br /&gt;
DROP       all  --  APoitiers-551-1-48-250.w92-146.abo.wanadoo.fr  anywhere&lt;br /&gt;
DROP       all  --  ip-83-134-25-126.dsl.scarlet.be  anywhere&lt;br /&gt;
DROP       all  --  192.168.1.245  anywhere&lt;br /&gt;
RETURN     all  --  anywhere             anywhere&lt;br /&gt;
&lt;br /&gt;
fail2ban-HTTP (1 references)&lt;br /&gt;
target     prot opt source               destination         &lt;br /&gt;
RETURN     all  --  anywhere             anywhere    &lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On peut voir que l'IP 192.168.1.245 s'est fais bannir via le filtre fail2ban-ssh&lt;br /&gt;
&lt;br /&gt;
Il faut compter le nombre de ligne d'Ip bannis jusqu’à celle que l'on veut débannir. Ici la 3eme ligne.&lt;br /&gt;
Ensuite une petite ligne de commande, il faudra bien entendu remplacer &amp;quot;fail2ban-ssh&amp;quot; par le nom du filtre qui a bannis l'ip et &amp;quot;3&amp;quot; par le numéro de la ligne correspondante.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ Console root | iptables -D fail2ban-ssh 3 }}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Relancer la première commande pour vérifier que l'Ip n'est plus dans la liste des adresses bannies.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ Avertissement | Il est fortement recommandé de redémarrer le service fail2ban si on débanni une IP manuellement }}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Tester son filtre ==&lt;br /&gt;
 &lt;br /&gt;
Many things can be tested after configuration but the following commands can help to verify your settings:&lt;br /&gt;
&lt;br /&gt;
 fail2ban-client -d&lt;br /&gt;
&lt;br /&gt;
will dump the current configuration.&lt;br /&gt;
&lt;br /&gt;
 fail2ban-regex &amp;quot;line&amp;quot; &amp;quot;failregex&amp;quot;&lt;br /&gt;
&lt;br /&gt;
will test a single regular expression failregex (such as given in sshd.conf) with a single line of your logfile. Don't forget the double quotes around your line and failregex definitions.&lt;br /&gt;
&lt;br /&gt;
fail2ban-regex accepts files too. Thus, it is easier to test and debug your own regular expressions.&lt;br /&gt;
&lt;br /&gt;
 fail2ban-regex /var/log/auth.log /etc/fail2ban/filter.d/sshd.conf&lt;br /&gt;
&lt;br /&gt;
You can use a combination of both:&lt;br /&gt;
&lt;br /&gt;
 fail2ban-regex /var/log/auth.log &amp;quot;Failed [-/\w]+ for .* from &amp;lt;HOST&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Différentes prison/jail ==&lt;br /&gt;
&lt;br /&gt;
Les prisons (jail) sont toujours à configurer dans {{ File | /etc/fail2ban/jail.conf }}&lt;br /&gt;
&lt;br /&gt;
=== SSH ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# SSH&lt;br /&gt;
# 2 retry ? &amp;gt; Ban for 15 minutes&lt;br /&gt;
[ssh]&lt;br /&gt;
enabled = true&lt;br /&gt;
port = ssh&lt;br /&gt;
filter = sshd&lt;br /&gt;
action = iptables[name=SSH, port=ssh, protocol=tcp]&lt;br /&gt;
logpath = /var/log/auth.log&lt;br /&gt;
maxretry = 2&lt;br /&gt;
bantime = 900&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Liens externes ==&lt;br /&gt;
[http://blog.nicolargo.com/2012/02/proteger-son-serveur-en-utilisant-fail2ban.html protéger son serveur avec fail2ban ] &amp;lt;br&amp;gt;&lt;br /&gt;
[http://blog.nicolargo.com/2012/03/bannir-les-bannis-avec-fail2ban.html Bannir les bannis avec fail2ban] &amp;lt;br&amp;gt;&lt;br /&gt;
http://doc.ubuntu-fr.org/fail2ban &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.commentcamarche.net/faq/18225-utiliser-fail2ban-pour-proteger-votre-application-web &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.fail2ban.org/wiki/index.php/MANUAL_0_8#Testing &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Catégorie:Système]]&lt;/div&gt;</summary>
		<author><name>Ddevleeschauwer</name></author>	</entry>

	</feed>