Fail2ban
侧边栏壁纸
  • 累计撰写 13 篇文章
  • 累计收到 32 条评论

Fail2ban

kinner
2024-01-06 / 6 评论 / 82 阅读 / 正在检测是否收录...

Ubuntu/Debian安装

sudo apt-get install fail2ban

源码安装

git clone https://github.com/fail2ban/fail2ban.git
cd fail2ban
sudo python setup.py install

Debian 12 手动安装 rsyslog

sudo apt-get install rsyslog

配置信息

cd /etc/fail2ban
cp jail.conf jail.local
cp fail2ban.conf fail2ban.local

注意,修改jail.local和fail2ban.local同样有效。输入vi jail.local可修改配置信息。
启动服务

sudo systemctl start fail2ban

开机启动

sudo systemctl enable fail2ban

服务状态

sudo systemctl status fail2ban

重启服务

systemctl restart fail2ban

查看启用

fail2ban-client status
fail2ban-client status sshd

手动解除限制ip

fail2ban-client unban 127.0.0.1
fail2ban-client unban --all

默认配置

#DEFAULT-START
[DEFAULT]
bantime = 600
findtime = 300
maxretry = 5
banaction = firewallcmd-ipset
action = %(action_mwl)s
#DEFAULT-END
    
[sshd]
ignoreip = 127.0.0.1/8               # 白名单
enabled = true
filter = sshd
port = 22                            # 端口
maxretry = 2                         # 最大尝试次数
findtime = 300                       # 发现周期 单位s
bantime = 600                        # 封禁时间,单位s。-1为永久封禁
action = %(action_mwl)s
banaction = iptables-multiport       # 禁用方式
logpath = /var/log/secure            # SSH 登陆日志位置
0

评论 (6)

取消
  1. 头像
    nfrckgjowu
    Windows 10 · Google Chrome

    Warning: Trying to access array offset on value of type null in /home/wwwroot/kinners/wwwroot/usr/themes/Joe/core/function.php on line 261
    @

    无语啊
    无语啊
    无语啊
    无语啊
    无语啊
    无语啊
    无语啊

    回复
  2. 头像
    gdoissszru
    Windows 10 · Google Chrome

    Warning: Trying to access array offset on value of type null in /home/wwwroot/kinners/wwwroot/usr/themes/Joe/core/function.php on line 261
    @

    你好,你好我的头发是。。。。。。

    回复
  3. 头像
    jplvwbdtss
    Windows 10 · Google Chrome

    Warning: Trying to access array offset on value of type null in /home/wwwroot/kinners/wwwroot/usr/themes/Joe/core/function.php on line 261
    @

    文字流畅如丝,语言优美动人,读来令人心旷神怡。

    回复
  4. 头像
    oeyjcyyveo
    Windows 10 · Google Chrome

    Warning: Trying to access array offset on value of type null in /home/wwwroot/kinners/wwwroot/usr/themes/Joe/core/function.php on line 261
    @

    情感表达稍显含蓄,可适当强化渲染。

    回复
  5. 头像
    rwlykkxkkl
    Windows 10 · Google Chrome

    Warning: Trying to access array offset on value of type null in /home/wwwroot/kinners/wwwroot/usr/themes/Joe/core/function.php on line 261
    @

    字里行间流露出真挚的情感,让人感同身受,共鸣不已。

    回复
  6. 头像
    bhkugstxxt
    Windows 10 · Google Chrome

    Warning: Trying to access array offset on value of type null in /home/wwwroot/kinners/wwwroot/usr/themes/Joe/core/function.php on line 261
    @

    字里行间流露出真挚的情感,让人感同身受,共鸣不已。

    回复