|
|
postfix 備忘録 Queue に溜まっているメールの確認 †# postqueue -p Queue にあるメールの削除 †# postsuper -d queue_id main.cf の設定変更 †main.cf に関するセキュリティ上の変更点 SMTPのVRFYコマンドを使用不可に †disable_vrfy_command = yes RFC822で定義されている書式に適合しないメールアドレスが通知された場合、受信を拒否 †strict_rfc821_envelopes = yes HELO コマンドでホスト名を通知しないホストの接続を拒否 †smtpd_helo_required = yes SMTP-AUTH(SMTP認証) †SMTP-AUTH(SMTP認証)とは、メールの送信時に認証を行うものです。 cyrus-sasl の設定 /usr/lib/sasl2/smtpd.conf pwcheck_method: saslauthd mech_list: cram-md5 plain login SASL認証用ユーザー/パスワードの設定 # saslpasswd2 -c <ユーザー> 自動起動するように設定 # chkconfig saslauthd on # chkconfig --list saslauthd saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off /etc/postfix/main.cf smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname smtpd_sasl_security_options = noanonymous, noplaintext broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination 上記について補足します。 sender_login_maps †SMTP認証したユーザーと送信するメールアドレスのユーザーが一致することを確認 smtpd_sender_restrictions = reject_sender_login_mismatch smtpd_sender_login_maps = hash:/etc/postfix/sasl_sender_login sasl_sender_login(postmapでDB化する) # メールアドレス saslpasswd2のユーザー+ドメイン aaa@example.jp aaa@mail.example.jp OP25B(Outbound Port 25 Blocking)対策 †自宅SMTPサーバーの接続ISPがOP25Bを導入した †自宅サーバーから送信する場合に、相手のSMTPサーバーに直接送信できなくなります。 今回、submissionポートを用いたSMTP送信認証サーバーを経由して送信する場合を想定して書いています。 /etc/postfix/main.cf ## Outbound Port 25 Blocking relayhost = [smtpauth.example.ne.jp]:submission smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_sasl_mechanism_filter = cram-md5, plain, login /etc/postfix/sasl_passwd(postmapでDB化します) [smtpauth.example.ne.jp]:submission isp_user:isp_passwd SMTPサーバーを利用するクライアント側ISPがOP25Bを導入した †OP25Bにより25番ポートが使用できなくなるので、別のポートで待ち受けるようにします。 Submission Port(ポート:587)の利用 †多くのISPで導入されている方法です。OP25Bが導入されると25番ポートが遮断されるため、その代替ポートとしてSubmission Port(ポート:587)を利用します。 submission inet n - n - - smtpd -o smtpd_enforce_tls=yes -o smtpd_sasl_auth_enable=yes -o smtpd_etrn_restrictions=reject SMTPS(SMTP over SSL/TLS. ポート:465)の利用 †SMTPS は本来暗号化により通信の秘匿性を保つためのものであるが、ポート番号として通常465番を使用するためOP25Bの影響を受けずにSMTPサーバと通信が可能になります。 smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes TLSサポート †メールの送信に際して、TLSによる暗号化がサポートされています。 /etc/postfix/main.cf ## smtp daemon smtpd_tls_cert_file = /etc/postfix/tls/server.crt smtpd_tls_key_file = /etc/postfix/tls/server.key smtpd_tls_CAfile = /etc/postfix/tls/root.crt smtpd_tls_session_cache_database = btree:/var/cache/postfix/smtpd_scache smtpd_use_tls = yes tls_random_exchange_name = /var/cache/postfix/prng_exch ## smtp client smtp_tls_cert_file = /etc/postfix/tls/server.crt smtp_tls_key_file = /etc/postfix/tls/server.key smtp_tls_CAfile = /etc/postfix/tls/root.crt smtp_tls_session_cache_database = btree:/var/cache/postfix/smtp_scache smtp_use_tls = yes server.crt … サーバー証明書 smtps(Port 465)を使用可能にする場合 # SMTP over SSL/TLS smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes エラーメッセージに関して †450 4.7.1 Client host rejected: cannot find your hostname †このメッセージはIPアドレスを逆引きして得られた名称が正引きできていないことを示している。 Backup MX に関する設定 †example.com のバックアップ MX を設定する場合には、以下の設定を追加します。 main.cf smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination relay_domains = $mydestination, example.com relay_recipient_maps = スパム対策 †postgrey †Postfix Greylisting Policy Server バーチャルドメイン †postfixadmin †postfix でバーチャルドメインをサポートするためのソフト |