ユーザ用ツール

サイト用ツール


ubuntu-server-10-04:postfix

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
ubuntu-server-10-04:postfix [2010/09/25 12:29] – な adminubuntu-server-10-04:postfix [2010/10/30 14:28] (現在) – [スパムの踏み台チェック] admin
行 1: 行 1:
 ====== Postfix でメールサーバ ====== ====== Postfix でメールサーバ ======
  
-本当にメールサーバとして利用するのではなく、+メールサーバとして Postfix をインストール。
  
  
行 46: 行 46:
   * Internet protocols to use   * Internet protocols to use
     * IPv4 しか使わないので ipv4 を選択     * IPv4 しか使わないので ipv4 を選択
-   
  
 +
 +メール保存形式をデフォルトの mbox から maildir に変更。
 +
 +  $ sudo postconf -e 'home_mailbox = Maildir/'
 +
 +
 +設定内容は /etc/postfix/main.cf に保存されている。
 +
 +
 +====== SMTP Authentication ======
 +
 +SASLを使って暗号化された回線でSMTP接続できるようにする。
 +
 +/etc/postfix/main.cf に以下を追加。
 +
 +<code>
 +smtpd_sasl_type = dovecot
 +smtpd_sasl_path = private/auth-client
 +smtpd_sasl_local_domain =
 +smtpd_sasl_security_options = noanonymous
 +broken_sasl_auth_clients = yes
 +smtpd_sasl_auth_enable = yes
 +smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
 +inet_interfaces = all
 +</code>
 +
 +サーバの鍵を用意する。[[ubuntu-server-10-04:self-signed_certificate|自己署名サーバ証明書の作成]]
 +
 +サーバの鍵を /etc/ssl/private/server.key に crtファイルを /etc/ssl/certs/server.crt に配置。
 +server.key はパスワードが解除してあるので、パーミッションとオーナーを変更しておく。
 +
 +  $ sudo chown root:ssl-cert /etc/ssl/private/server.key
 +  $ sudo chmod 640 /etc/ssl/private/server.key
 +
 +CAの証明書を /etc/ssl/certs/cacert.pem に配置。
 +
 +/etc/postfix/main.cf に以下を追加。
 +<code>
 +smtpd_tls_auth_only = no
 +smtp_use_tls = yes
 +smtpd_use_tls = yes
 +smtp_tls_note_starttls_offer = yes
 +smtpd_tls_key_file = /etc/ssl/private/server.key
 +smtpd_tls_cert_file = /etc/ssl/certs/server.crt
 +smtpd_tls_loglevel = 1
 +smtpd_tls_received_header = yes
 +smtpd_tls_session_cache_timeout = 3600s
 +tls_random_source = dev:/dev/urandom
 +myhostname = mail.example.com
 +
 +smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem
 +</code>
 +  * mail.example.com はサーバのアドレスに置き換える
 +
 +最後に Postfix を再起動。
 +
 +  $ sudo /etc/init.d/postfix restart
 +
 +====== SASLの設定 ======
 +
 +AMTP Authentication で使用する SASL を設定する。
 +
 +必要なパッケージをインストール。
 +
 +  $ sudo apt-get install dovecot-common
 +
 +/etc/dovecot/dovecot.conf を編集する。socket listen を検索して以下のように変更。
 +
 +<code>
 +  socket listen {
 +    #master {
 +      # Master socket provides access to userdb information. It's typically
 +      # used to give Dovecot's local delivery agent access to userdb so it
 +      # can find mailbox locations.
 +      #path = /var/run/dovecot/auth-master
 +      #mode = 0600
 +      # Default user/group is the one who started dovecot-auth (root)
 +      #user =
 +      #group =
 +    #}
 +    client {
 +      # The client socket is generally safe to export to everyone. Typical use
 +      # is to export it to your SMTP server so it can do SMTP AUTH lookups
 +      # using it.
 +      #path = /var/run/dovecot/auth-client
 +      path = /var/spool/postfix/private/auth-client
 +      mode = 0660
 +      user = postfix
 +      group = postfix
 +    }
 +  }
 +</code>
 +
 +Outlook から接続する場合は mechanisms に login を追加。
 +
 +  $   mechanisms = plain login
 +
 +====== テスト ======
 +
 +設定が終わったら telnet でテストする。
 +
 +  $ telnet mail.example.com 25
 +
 +telnet から以下のコマンドを実行。
 +
 +  ehlo mail.example.com
 +
 +以下の出力が含まれていれば OK。"LOGIN" は Outlook のための設定を行った場合に表示される。
 +
 +<code>
 +250-STARTTLS
 +250-AUTH LOGIN PLAIN
 +250-AUTH=LOGIN PLAIN
 +250 8BITMIME
 +</code>
 +
 +
 +====== SSL/TLS接続を有効にする ======
 +
 +STARTTLS ではなく直接465ポートにアクセスして暗号化接続を行えるようにする。
 +
 +<code>
 +$ sudo vi /etc/postfix/master.cf
 +</code>
 +
 +コメントを3行分はずす。
 +
 +<code>
 +smtps     inet  n                               smtpd
 +  -o smtpd_tls_wrappermode=yes
 +  -o smtpd_sasl_auth_enable=yes
 +#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
 +#  -o milter_macro_daemon_name=ORIGINATING
 +</code>
 +
 +その後再起動かリロード。
 +
 +<code>
 +$ sudo /etc/init.d/postfix restart
 +</code>
 +
 +
 +
 +
 +====== スパムの踏み台チェック ======
 +
 +外部からの不正リレーをきちんと防げているかをチェックするには、メールサーバから以下のコマンドを実行する。
 +
 +<code>
 +$ telnet relay-test.mail-abuse.org
 +</code>
 +
 +  * 参考: [[http://www.postfix-jp.info/origdocs/antispam.html|Postfix antispam]]
 +
 +
 +===== root 宛てのメールを転送 =====
 +
 +root にメールを送信されても受信する機会がないので、root 宛てのメールはシステム管理をするユーザに転送する。
 +
 +<code>
 +$ sudo vi /etc/aliases
 +</code>
 +root 宛てのメッセージを他のユーザに転送する。
 +<code>
 +# See man 5 aliases for format
 +postmaster:    root
 +
 +root:   foobar
 +</code>
 +
 +/etc/aliases を編集した後に以下のコマンドで設定を適用する。
 +<code>
 +$ sudo newaliases
 +</code>
  
  
ubuntu-server-10-04/postfix.1285385359.txt.gz · 最終更新: 2010/09/25 12:29 by admin