1 インストール#
Ubuntu / Debian
1、Fail2banをインストール
sudo apt-get install fail2ban
2、Debian 12 以上のバージョンではrsyslogを手動でインストールする必要があります
sudo apt-get install rsyslog
3、Fail2banサービスを起動
sudo systemctl start fail2ban
4、起動時に自動起動
sudo systemctl enable fail2ban
5、Fail2banサービスの状態を確認します。
sudo systemctl status fail2ban
2 デフォルト設定#
1Panel はデフォルトで以下の設定を使用します:
#DEFAULT-START
[DEFAULT]
bantime = 600
findtime = 300
maxretry = 5
banaction = ufw
action = %(action_mwl)s
#DEFAULT-END
[sshd]
ignoreip = 127.0.0.1/8
enabled = true
filter = sshd
port = 22
maxretry = 3
findtime = 300
bantime = -1
banaction = ufw
action = %(action_mwl)s
logpath = /var/log/auth.log
3 UFW 設定の変更#
/etc/fail2ban/action.d/ufw.conf
[Definition]
actionstart =
actionstop =
actioncheck =
# すべてのポートアクセスを禁止
actionban = ufw insert 1 deny from <ip> to any
actionunban = ufw delete deny from <ip> to any
[Init]