メモ > サーバ > 構築: 攻撃からの防御 > fail2ban(侵入防御ツール)導入
■fail2ban(侵入防御ツール)導入
# yum install fail2ban
# vi /etc/fail2ban/jail.local
… 設定ファイルを編集(/etc/fail2ban/jail.conf は直接編集しない)
[ssh-iptables]
enabled = true … 設定を有効にする
filter = sshd … フィルタ名
action = iptables[name=SSH, port=10022, protocol=tcp] … アクション
sendmail-whois[name=SSH, dest=root, sender=fail2ban@refirio.net]
logpath = /var/log/sshd.log … 監視するログファイル
maxretry = 5 … 最大リトライ回数
※上の設定で「SSHでの接続に5回失敗すれば、接続元をブロックする」となる
# service fail2ban start … fail2banを起動
fail2ban を起動中: [ OK ]
# chkconfig fail2ban on … fail2banの自動起動を設定
# iptables -L … iptablesの内容を確認
Chain fail2ban-SSH (1 references) … 最後に設定が追加されている
target prot opt source destination
RETURN all -- anywhere anywhere
※/etc/sysconfig/iptables を編集してiptablesを再起動した場合、
iptablesにあるfail2banの設定内容が消えるので、fail2banを再起動する必要がある?
自動起動に設定しておけば問題ない?