Postfixで特定のエンベロープの送信者ドメインのメールを拒否する
カテゴリ:メールサーバ
特定の送信者ドメイン(ユーザー名はランダム)で送信されるスパムメールが大量に来る事があります。その場合に、Postfix でエンベロープの送信者ドメインで受信を拒否する設定を作る方法です。
まず、Postfix の設定ディレクトリ(/etc/postfix)配下に拒否する送信者用のマップファイル(reject_sender)を作ります。
# cd /etc/postfix # touch reject_sender
reject_sender をエディタで開き、拒否したいドメインと処理を登録します。
※下記では qq.com をリジェクトします
# vi reject_sender qq.com REJECT
マップファイルのdbを生成します。
# postmap reject_sender
reject_sender.db が生成されている事を確認します。
# ls access generic main.cf reject_sender relocated virtual canonical header_checks master.cf reject_sender.db transport
Postfix の smtpd_sender_restrictions パラメータにそのマップファイルを指定します。
# postconf -e smtpd_sender_restrictions=hash:/etc/postfix/reject_sender
念のため設定が反映されている事を確認。
# postconf smtpd_sender_restrictions smtpd_sender_restrictions = hash:/etc/postfix/reject_sender
Postfix をリロードして設定を反映させます。
# postfix reload postfix/postfix-script: refreshing the Postfix mail system
試しに telnet コマンドでテストし、rcpt to を受け取った後に 554 の応答コードで拒否している事を確認します。
# telnet localhost 25 Trying ::1... Connected to localhost. Escape character is '^]'. 220 hacentos7.prime ESMTP Postfix helo fqdn 250 hacentos7.prime mail from: test@qq.com 250 2.1.0 Ok rcpt to: test@example.com 554 5.7.1: Sender address rejected: Access denied
公開日時:2017年08月29日 21:12:55