#author("2017-01-01T20:49:36+09:00","default:auth_user","auth_user") *Postfix Configration Manual [#v06a069c] *目次 [#i20b2b56] #contents **Postfixのインストール [#z004a3b2] ***Postfix用ユーザ・グループの作成 [#n84af90b] Postfix用のユーザとグループを新規に作成します。 ユーザ名:postfix グループ名:postdrop groupadd -g 810 postdrop useradd -u 811 -d /nonexistent -s /sbin/nologin postfix postfixユーザのグループをpostdropにするとエラーが出ます。 ご注意!! ***ファイルの展開・コンパイル [#zf7ee7b8] ファイルを展開しコンパイル tar zxvf postfix-2.1.5.tar.gz cd postfix-2.1.5 make エラーなくコンパイルができたらインストール make install インストールの際に以下のことを聞かれる Warning: if you use this script to install Postfix locally, this script will replace existing sendmail or Postfix programs. Make backups if you want to be able to recover. Before installing files, this script prompts you for some definitions. Most definitions will be remembered, so you have to specify them only once. All definitions should have a reasonable default value. Please specify the prefix for installed file names. Specify this ONLY if you are building ready-to-install packages for distribution to other machines. install_root: [/] Please specify a directory for scratch files while installing Postfix. You must have write permission in this directory. tempdir: [/usr/src/postfix-2.1.5] /usr/local/postfix Please specify the final destination directory for installed Postfix configuration files. config_directory: [/etc/postfix] Please specify the final destination directory for installed Postfix daemon programs. This directory should not be in the command search path of any users. daemon_directory: [/usr/libexec/postfix] Please specify the final destination directory for installed Postfix administrative commands. This directory should be in the command search path of adminstrative users. command_directory: [/usr/sbin] Please specify the final destination directory for Postfix queues. queue_directory: [/var/spool/postfix] Please specify the final destination pathname for the installed Postfix sendmail command. This is the Sendmail-compatible mail posting interface. sendmail_path: [/usr/sbin/sendmail] Please specify the final destination pathname for the installed Postfix newaliases command. This is the Sendmail-compatible command to build alias databases for the Postfix local delivery agent. newaliases_path: [/usr/bin/newaliases] Please specify the final destination pathname for the installed Postfix mailq command. This is the Sendmail-compatible mail queue listing command. mailq_path: [/usr/bin/mailq] Please specify the owner of the Postfix queue. Specify an account with numerical user ID and group ID values that are not used by any other accounts on the system. mail_owner: [postfix] Please specify the group for mail submission and for queue management commands. Specify a group name with a numerical group ID that is not shared with other accounts, not even with the Postfix mail_owner account. You can no longer specify "no" here. setgid_group: [postdrop] Please specify the destination directory for the Postfix HTML files. Specify "no" if you do not want to install these files. html_directory: [no] Please specify the destination directory for the Postfix on-line manual pages. You can no longer specify "no" here. manpage_directory: [/usr/local/man] Please specify the destination directory for the Postfix README files. Specify "no" if you do not want to install these files. readme_directory: [no] 基本的にデフォルトのままでいいが、TMPディレクトリだけは別で用意したほうがいい。 少なからず、私はインストールが完了した場合ソースの入ったディレクトリを削除してしまうことがあるからである。 ***main.cfの編集 [#a8e3a0ed] main.cfを編集する。 その前にオリジナルファイルを必ずバックアップしておく。 main.cf.defaultというファイルがあったが、中を見るとmain.cfのコピーではなくデフォルト設定の一覧だけであり、 解説部分がない上に、表示の順番が違うためわかりにくい。 ということで、main.cfをコピーして取っておく事をおすすめする。 cd /etc/postfix cp main.cf main.cf.orig いよいよmain.cfの編集へと続く myhostname = hoge.jp mydomain = hoge.jp myorigin = $mydomain inet_interfaces = all mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain mynetworks_style = subnet mynetworks = 192.168.0.0/24, 127.0.0.0/8 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mail_spool_directory = /var/spool/mail smtpd_banner = $myhostname ESMTP $mail_name とりあえず、主として変更するところはこの辺だと思う。 設定終了後Posrfixを起動 /usr/sbin/postfix start エラーが表示されたらmain.cfを再編集し、Postfixが起動するまで繰り返す。 **SMTPAuthenticationの導入 [#r97d058b] メール送信のためにPOP Before SMTPを使う人もいるが、送信時に認証を加えたほうがよい。 POP Before SMTPではNAT環境において自分のPC以外からリレーを許可してしまう場合があるからである。 ということで、今回はSMTPAuthを導入。 ***Postfixのリコンパイル [#ac0a3caf] SMTPAuthをONにするためPostfixをリコンパイルする make tidy make makefiles CCARGS="-DUSE_SASL_AUTH -I/usr/include" AUXLIBS="-L/usr/lib -lsasl" make ***パスワードデータベースの指定 [#id02f4da] sasldbを認証DBとして使うと指定 echo pwcheck_method:sasldb > /usr/lib/sasl/smtpd.conf ***パスワードの設定 [#q42e7047] ユーザの追加・作成(2人目を作成する場合からは”-c”オプションが必要なくなる) saslpasswd -c -u hoge.jp hoge ユーザの削除 saslpasswd -d -u hoge.jp hoge ユーザ一覧の表示 sasldblistusers ***データベースファイルの設定変更 [#f6208b8a] Postfixがデータベースを扱えるようにグループとパーミッションを変更する。 chgrp postfix /etc/sasldb chmod 640 /etc/sasldb ***main.cfの再設定 [#r104023e] main.cfの一番下に以下の設定を追加する。 #SASL configuration smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes その後Postfixを再起動する。 /usr/sbin/postfix reload **SMTPAuth+TLSの導入 [#w44874ab] 意外と難しいことが判明 ちょっと持ち越しの可能性大 * 参考リンク [#e5a7cd55] >> [[Postfix のぺーじ:http://www.kobitosan.net/postfix/]]