Fail2ban指南:修订间差异

来自MediaWiki
跳转到导航 跳转到搜索
Admin留言 | 贡献
无编辑摘要
Admin留言 | 贡献
无编辑摘要
标签wikieditor
第1行: 第1行:
编写文件 /etc/fail2ban/filter.d/frps.conf
==fail2ban==
<pre>
 
[Definition]
=== 安装 ===
failregex = ^.*get a user connection \[<HOST>:[0-9]*\]
'''apt install fail2ban'''
            ^.*get a new work connection: \[<HOST>:[0-9]*\]
 
ignoreregex =
=== 配置 ===
</pre>
 
编写文件 /etc/fail2ban/jail.local 添加(以frp为例)
 
<pre>
vim /etc/fail2ban/jail.local<syntaxhighlight lang="bash">
[frp]
[sshd]               
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 确认服务状态
 
[[分类:Linux]]
=== 日志 ===
[[分类:命令行工具]]
/var/log/fail2ban.log

2023年10月16日 (一) 05:36的版本

fail2ban

安装

apt install fail2ban

配置

vim /etc/fail2ban/jail.local

[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