fail2banでサーバーを守ります。
smtpとか公開するとアタックされやすいようです。
予測しやすいユーザー名やパスワードは使用しないことが原則ですが公開鍵認証を設定していてもアタックログは気持ち悪いですよね。
ほぼ海外からだから余計にブルーな気分になります。
環境
# httpd -v
Server version: Apache/2.4.6 (CentOS)
# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
インストール
yum install fail2ban
設定ファイル追記
下記サイトを参考に設定しました
https://gtrt7.com/blog/linux/fail2ban
https://blog.jicoman.info/2014/03/fail2ban_install/
https://qiita.com/pypypyo14/items/cfcaad2783debfafe505
編集ファイル
jail.localを新規作成し、設定を追加で読み込みさせるイメージです。
もとの設定ファイルを変更しないので編集するのにためらいがなくて精神衛生上よいです。
vi /etc/fail2ban/jail.local
必要なら下記ファイルの編集もすると良いでしょう。
vi /etc/fail2ban/action.d/iptables-common.conf
初期状態は「REJECT」になっているので変更したい場合は編集する
blocktype = REJECT #(拒否)
blocktype = DROP #(破棄)
起動、自動起動設定
# systemctl start fail2ban
# systemctl enable fail2ban
# systemctl is-enabled fail2ban
enabled
その他ログローテションなどは各自お好みで設定すると良いです。
Tips
ブロックしたIPを確認する
fail2ban-client status sshd
fail2ban-client status postfix-sasl
fail2banコマンドmemo
systemctl stop fail2ban
systemctl start fail2ban
systemctl restart fail2ban
systemctl status fail2ban
systemctl enable fail2ban
ps.アタック業者は広告踏んでくれればいいのにね。
コメント