Mail サーバー : Postfix インストール2025/09/23 |
|
Postfix をインストールして SMTP サーバーを構築します。SMTP は [25/TCP] を使用します。 |
|
| [1] | メール不正中継防止に、後述の Dovecot の SASL機能を利用し、送信にも認証が必要なように Postfix を設定します。 |
|
root@mail:~#
apt -y install postfix sasl2-bin # 一般的な構成設定の選択を求められるが # 当例では後ほど手動設定するため [No Configuration] を選択 +------+ Postfix Configuration +-------+ | General type of mail configuration: | | | | No configuration | | Internet Site | | Internet with smarthost | | Satellite system | | Local only | | | | | | <Ok> <Cancel> | | | +--------------------------------------+root@mail:~# cp /usr/share/postfix/main.cf.dist /etc/postfix/main.cf
root@mail:~#
vi /etc/postfix/main.cf # 82行目 : コメント解除 mail_owner = postfix # 97行目 : IPv4 のみリスンする場合は [ipv4] に変更 inet_protocols = all # 107行目 : コメント解除しホスト名指定 myhostname = mail.srv.world # 114行目 : コメント解除しドメイン名指定 mydomain = srv.world # 133行目 : 変更 myorigin = $mydomain # 149行目 : コメント解除 inet_interfaces = all # 197行目 : コメント解除 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain # 285行目 : コメント解除 mynetworks_style = subnet # 299行目 : 自ネットワーク追記 mynetworks = 127.0.0.0/8, 10.0.0.0/24 # 423行目 : コメント解除 alias_maps = hash:/etc/aliases # 434行目 : コメント解除 alias_database = hash:/etc/aliases # 456行目 : コメント解除 home_mailbox = Maildir/ # 592行目 : コメントにしてその下に追記 # SMTP ソフトウェアの種類やバージョンは非表示にする #smtpd_banner = $myhostname ESMTP $mail_name (Debian) smtpd_banner = $myhostname ESMTP # 665行目 : コメント解除 sendmail_path = /usr/sbin/postfix # 670行目 : コメント解除 newaliases_path = /usr/bin/newaliases # 675行目 : コメント解除 mailq_path = /usr/bin/mailq # 681行目 : コメント解除 setgid_group = postdrop # 以下 最終行へ追記 # SMTP VRFY コマンドは無効にする disable_vrfy_command = yes # クライアントに対して HELO コマンドを要求する smtpd_helo_required = yes # 1 メールのサイズを制限する # 下例は 10M バイト message_size_limit = 10240000 # SMTP-Auth の設定 smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous smtpd_sasl_local_domain = $myhostname smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destinationroot@mail:~# touch /etc/aliases root@mail:~# root@mail:~# systemctl restart postfix |
| [2] |
必要に応じて Postfix に以下の設定を追加します。
ただし、必要なメールを拒否することもしばしばあります。 |
|
root@mail:~#
vi /etc/postfix/main.cf # 最終行に追記 # 送信元クライアントホストの DNS の正引きと逆引きが一致しない場合は接続要求を拒否する smtpd_client_restrictions = permit_mynetworks, reject_unknown_client_hostname, permit # FROM に設定されている送信者アドレスのドメインが DNS 登録にない または # FQDN で登録されていない場合は接続要求を拒否する smtpd_sender_restrictions = permit_mynetworks, reject_unknown_sender_domain, reject_non_fqdn_sender # HELO コマンドを受信した際に 接続元ホスト名が DNS に登録されていない または # FQDN で登録されていない場合は接続要求を拒否する smtpd_helo_restrictions = permit_mynetworks, reject_unknown_hostname, reject_non_fqdn_hostname, reject_invalid_hostname, permit systemctl reload postfix |
| Sponsored Link |
|
|