postfixのSASL LOGIN authentication failed攻撃をIP制限で遮断する

25番ポートでメールサーバを運用していると、まあアタックを受ける。昨晩から発生しているのは、辞書攻撃でもしているようで、毎秒1回の頻度でSASL LOGINを試みている。おかげでサーバが不安定になってしまっているので、本気で排除することにした。

こんな感じのログがぶわーーーっと伸びていく。腹立たしい。

Oct 18 03:50:55 yashima postfix/smtpd[23631]: connect from unknown[45.142.120.54]
Oct 18 03:50:58 yashima postfix/smtpd[23659]: warning: unknown[45.142.120.54]: SASL LOGIN authentication failed: authentication failure

reject_clientを作ってsmtpd_client_restrictions で拒否する案

色々調べて、拒否IPリストを作ってsmtpd_client_restrictionsに突っ込むことにした。

広告

あらかじめ、拒否IPリストをこんな形式で作っておく。

sudo vi /etc/postfix/reject_client
212.70.149 REJECT
45.142.120 REJECT

hashで読み込ませるので、postmapしておく。

sudo postmap /etc/postfix/reject_client

main.cfにはこんな記述を入れておく。

sudo vi /etc/postfix/main.cf
smtpd_client_restrictions = permit_mynetworks,
     check_client_access hash:/etc/postfix/reject_client,
     reject_unknown_client,
     reject_invalid_hostname,
     permit

postfixをリロード。

sudo systemctl reload postfix

これがどうにもうまく行かない。restartにしてもだめ。相変わらず、もりもりとSASL LOGIN試行が延々と続いている。
smtpd_client_restrictionsだけじゃなくて、smtpd_sender_restrictionsにしてみたりsmtpd_helo_restrictionsにしてみたりsmtpd_recipient_restrictionsにしてみたりと試行錯誤したんだけど、全然REJECTしてくれない。

次善策 iptablesで遮断

centOS7って、サーバのFirewall機能がiptablesからfirewalldに移った、というイメージだったけど、iptablesも依然として使えるんですね。

sudo iptables -I INPUT -s 212.70.149.0/24 -j DROP
$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
DROP       all  --  212.70.149.0/24      anywhere

これでピタリと止みました。

About: dacelo


1 thought on “postfixのSASL LOGIN authentication failed攻撃をIP制限で遮断する”

Leave a Reply

Your email address will not be published. Required fields are marked *