<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/index.php?action=history&amp;feed=atom&amp;title=User%3AJch%2Ffail2ban</id>
	<title>User:Jch/fail2ban - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/index.php?action=history&amp;feed=atom&amp;title=User%3AJch%2Ffail2ban"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:Jch/fail2ban&amp;action=history"/>
	<updated>2026-05-05T16:50:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:Jch/fail2ban&amp;diff=11022&amp;oldid=prev</id>
		<title>Jch: How to setup fail2ban on a log server to control a remote firewall</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:Jch/fail2ban&amp;diff=11022&amp;oldid=prev"/>
		<updated>2015-06-25T09:28:20Z</updated>

		<summary type="html">&lt;p&gt;How to setup fail2ban on a log server to control a remote firewall&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{draft}}&lt;br /&gt;
&lt;br /&gt;
= How to setup fail2ban on a log server to control a remote firewall =&lt;br /&gt;
&lt;br /&gt;
I want to follow auth.log on a syslog-ng server running in a LXC to update iptables on a separate firewall machine.&lt;br /&gt;
&lt;br /&gt;
Installation is easy but it doesn&amp;#039;t work (yet) as expected.&amp;lt;br/&amp;gt;&lt;br /&gt;
Even if it&amp;#039;s working from the command line :(&lt;br /&gt;
&lt;br /&gt;
The syslog-ng machine is called &amp;quot;cerberus&amp;quot;.&amp;lt;br/&amp;gt;&lt;br /&gt;
The firewall is called &amp;quot;firewall&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
First, cerberus has to be able to log without password on firewall with root credentials (to update the iptables rules). This is done with usual id_rsa private and public key (in /root/.ssh/authorized_keys on firewall).&lt;br /&gt;
&lt;br /&gt;
Next is to add a wrapper script for iptables commands. I did it in /usr/local/bin/do with &amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
logger -t do_firewall &amp;quot;$1&amp;quot;&lt;br /&gt;
ssh -l root -p22 -i /root/.ssh/id_rsa firewall &amp;quot;$1&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This wrapper was added in front of rules in /etc/fail2ban/action.d/iptables.conf like (to all rules) &amp;lt;pre&amp;gt;&lt;br /&gt;
actionstop = /usr/local/bin/do &amp;quot;iptables -D &amp;lt;chain&amp;gt; -p &amp;lt;protocol&amp;gt; --dport &amp;lt;port&amp;gt; -j f2b-&amp;lt;name&amp;gt;&amp;quot;&lt;br /&gt;
             /usr/local/bin/do &amp;quot;iptables -F f2b-&amp;lt;name&amp;gt;&amp;quot;&lt;br /&gt;
             /usr/local/bin/do &amp;quot;iptables -X f2b-&amp;lt;name&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is working as expected when manually invoked&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cerberus:~# fail2ban-client start&lt;br /&gt;
cerberus:~# fail2ban-client set sshd banip 4.34.47.232&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But nothing happens from the fail2ban daemon :(&lt;/div&gt;</summary>
		<author><name>Jch</name></author>
	</entry>
</feed>