Fail2ban: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| (5 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== | == Installation == | ||
{{Root|emerge fail2ban}} | {{Root|emerge fail2ban}} | ||
| Line 9: | Line 9: | ||
{{Root|rc-update add fail2ban default}} | {{Root|rc-update add fail2ban default}} | ||
== syslog-ng configuration == | |||
{{File|/etc/syslog-ng/syslog-ng.conf| | |||
{{File|/etc/ | |||
<pre> | <pre> | ||
source src { system(); internal(); }; | |||
destination authlog { file("/var/log/auth.log"); }; | destination authlog { file("/var/log/auth.log"); }; | ||
filter f_authpriv { facility(auth, authpriv); }; | filter f_authpriv { facility(auth, authpriv); }; | ||
log { source(src); filter(f_authpriv); destination(authlog); }; | |||
destination messages { file("/var/log/messages"); }; | |||
</pre> | </pre> | ||
}} | }} | ||
| Line 49: | Line 29: | ||
{{Root|/etc/init.d/syslog-ng restart}} | {{Root|/etc/init.d/syslog-ng restart}} | ||
{{File|/etc/fail2ban. | == Fail2ban configuration (0.9.x) == | ||
Be sure to also enable the required Kernel options for [[Kernel#Fail2ban_.28iptables.29|iptables]]. | |||
=== Enable the sshd jails and fail2ban reporting via email === | |||
{{File|/etc/fail2ban/jail.local| | |||
<pre> | <pre> | ||
[DEFAULT] | |||
bantime = 86400 | |||
[ | maxretry = 3 | ||
destemail = yourmail@domain.local | |||
sender = fail2ban@hostname | |||
action = %(action_mwl)s | |||
[ | [sshd] | ||
enabled = true | enabled = true | ||
</pre> | </pre> | ||
}} | }} | ||
=== Optional: Disable the new sqlite feature === | |||
{{File|/etc/fail2ban/fail2ban.local| | |||
{{ | |||
<pre> | <pre> | ||
[Definition] | |||
dbfile = None | |||
</pre> | </pre> | ||
}} | }} | ||
=== Optional: Set the sshd log file path (default is auth.log) === | |||
{{File|/etc/ | {{File|/etc/fail2ban/paths-overrides.local| | ||
<pre> | <pre> | ||
[DEFAULT] | |||
sshd_log = /var/log/sshd.log | |||
</pre> | </pre> | ||
}} | }} | ||
{{Root|/etc/init.d/fail2ban start}} | {{Root|/etc/init.d/fail2ban start}} | ||
Latest revision as of 13:35, 20 May 2018
Installation
# emerge fail2ban
# /etc/init.d/iptables save
# rc-update add iptables default
# rc-update add fail2ban default
syslog-ng configuration
File: /etc/syslog-ng/syslog-ng.conf
source src { system(); internal(); };
destination authlog { file("/var/log/auth.log"); };
filter f_authpriv { facility(auth, authpriv); };
log { source(src); filter(f_authpriv); destination(authlog); };
destination messages { file("/var/log/messages"); };
# touch /var/log/auth.log
# chmod 600 /var/log/auth.log
# /etc/init.d/syslog-ng restart
Fail2ban configuration (0.9.x)
Be sure to also enable the required Kernel options for iptables.
Enable the sshd jails and fail2ban reporting via email
File: /etc/fail2ban/jail.local
[DEFAULT] bantime = 86400 maxretry = 3 destemail = yourmail@domain.local sender = fail2ban@hostname action = %(action_mwl)s [sshd] enabled = true
Optional: Disable the new sqlite feature
File: /etc/fail2ban/fail2ban.local
[Definition] dbfile = None
Optional: Set the sshd log file path (default is auth.log)
File: /etc/fail2ban/paths-overrides.local
[DEFAULT] sshd_log = /var/log/sshd.log
# /etc/init.d/fail2ban start