Fail2ban指南:修订间差异

来自MediaWiki
跳转到导航 跳转到搜索
Admin留言 | 贡献
导入1个版本
 
Admin留言 | 贡献
无编辑摘要
 
(未显示同一用户的3个中间版本)
第1行: 第1行:
编写文件 /etc/fail2ban/filter.d/frps.conf
= 安装 =
<pre>
'''apt install fail2ban'''
[Definition]
 
failregex = ^.*get a user connection \[<HOST>:[0-9]*\]
= 配置 =
            ^.*get a new work connection: \[<HOST>:[0-9]*\]
vim /etc/fail2ban/jail.local
ignoreregex =
 
</pre>
== SSH ==
编写文件 /etc/fail2ban/jail.local 添加(以frp为例)
<syntaxhighlight lang="bash">
<pre>
[sshd]               
[frp]
enabled = true
enabled = true
findtime = 300
port = 14213
maxretry = 3
filter = sshd
bantime = -10d
logpath = /var/log/auth.log
filter = frps
maxretry = 5
logpath = /home/log/frps.log
bantime = 12h
protocol = all
</syntaxhighlight>
chain = all
 
port = all
=重启查看状态 =
action = iptables-allports[name=frp,protocol=tcp]
service fail2ban restart
        mail[name=frp, dest=w1073@qq.com]
 
</pre>
'''fail2ban-client status sshd'''
fail2ban-client reload 重载服务和 fail2ban-client status frp 确认服务状态
 
= 日志 =
/var/log/fail2ban.log

2023年10月16日 (一) 05:37的最新版本

安装[编辑 | 编辑源代码]

apt install fail2ban

配置[编辑 | 编辑源代码]

vim /etc/fail2ban/jail.local

SSH[编辑 | 编辑源代码]

[sshd]               
enabled = true
port = 14213
filter = sshd
logpath = /var/log/auth.log
maxretry = 5
bantime = 12h

重启查看状态[编辑 | 编辑源代码]

service fail2ban restart

fail2ban-client status sshd

日志[编辑 | 编辑源代码]

/var/log/fail2ban.log