「Postfix」の設定

Solaris10のメールサーバのデフォルトは「Sendmail」ですが、セキュリティや設定の容易さ等の理由により、 「Postfix」を利用することにします。
その為、デフォルトでインストールされている「Sendmail」はアンインストールします。
POP+IMAPサーバには「Courier-IMAP」を用いることを前提に設定します。
また、ここでは「Postfix」のバージョンは2.5.1としています。
2.2.4の場合はこちらを参照して下さい。
なお、「Outbound Port25 Blocking」への対応方法はこちらを参照して下さい。

「Sendmail」のアンインストール

デフォルトでインストールされている「Sendmail」をアンインストールします。
ただし、エイリアスファイルは「Postfix」のインストール後、利用しますので、バックアップを取っておきます。

Solaris# cp /etc/aliases /etc/aliases.org  <= エイリアスファイルのバックアップ

Solaris# svcs -a | grep -i sendmail <= 「Sendmail」の状態確認
online         12:31:23 svc:/network/smtp:sendmail
Solaris# svcadm disable svc:/network/smtp:sendmail <= 「Sendmail」の停止

Solaris# pkginfo | grep -i sendmail <= 「Sendmail」のインストール状態の確認
system      SUNWsndmr                        Sendmail (root)
system      SUNWsndmu                        Sendmail (/usr)

Solaris# pkgrm SUNWsndmr SUNWsndmu <= 「Sendmail」のアンインストール

Do you want to remove this package? [y,n,?,q] y

Do you want to continue with the removal of this package [y,n,?,q] y

Do you want to continue with the removal of this package [y,n,?,q] y

Do you want to remove this package? [y,n,?,q] y
「Postfix」のインストール

「Postfix」用のユーザを作成します。

Solaris# groupadd -g 10001 postfix
Solaris# groupadd -g 10002 postdrop
Solaris# useradd -u 10001 -g postfix -d /var/spool/postfix -s /bin/false postfix

「Postfix」のソースファイルをダウンロードし、インストールします。

Solaris# mkdir /usr/local/src/postfix <= 作業用ディレクトリの作成
Solaris# chmod 777 /usr/local/src/postfix <= 作業用ディレクトリのパーミッション変更
Solaris# exit <= 一般ユーザになる
Solaris% cd /usr/local/src/postfix <= 作業用ディレクトリへ移動
Solaris% wget ftp://ftp.t.ring.gr.jp/pub/net/mail/postfix/official/postfix-2.5.1.tar.gz
 <= 「Postfix」のソースをダウンロード
Solaris% gunzip -c postfix-2.5.1.tar.gz | tar xf - <= ダウンロードしたファイルの展開
Solaris% cd postfix-2.5.1 <= 展開したディレクトリに移動
Solaris% gmake |& tee make.log <= コンパイル
Solaris% su <= スーパーユーザになる
Password: <= パスワードの入力
Solaris# gmake install |& tee make-install.log <= インストール

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: [/] <= 空Enter

Please specify a directory for scratch files while installing Postfix.
You must have write permission in this directory.
tempdir: [/usr/local/src/postfix/postfix-2.5.1] <= 空Enter

Please specify the final destination directory for installed Postfix
configuration files.
config_directory: [/etc/postfix] <= 空Enter

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] <= 空Enter

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] <= 空Enter

Please specify the final destination directory for Postfix-writable
data files such as caches or random numbers. This directory should not
be shared with non-Postfix software.
data_directory: [/var/lib/postfix] <= 空Enter

Please specify the destination directory for the Postfix HTML files.
Specify "no" if you do not want to install these files.
html_directory: [no] <= 空Enter

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] <= 空Enter

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] <= 空Enter

Please specify the destination directory for the Postfix on-line manual
pages. You can no longer specify "no" here.
manpage_directory: [/usr/local/man] <= 空Enter

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] <= 空Enter

Please specify the final destination directory for Postfix queues.
queue_directory: [/var/spool/postfix] <= 空Enter

Please specify the destination directory for the Postfix README files.
Specify "no" if you do not want to install these files.
readme_directory: [no] <= 空Enter

Please specify the final destination pathname for the installed Postfix
sendmail command. This is the Sendmail-compatible mail posting
interface.
sendmail_path: [/usr/lib/sendmail] <= 空Enter

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] <= 空Enter
「Postfix」の設定
Solaris# vi /etc/postfix/main.cf <= 設定ファイルの編集

#myhostname = host.domain.tld
↓
myhostname = Solaris.crimson-snow.net <= ホストネームを指定

#mydomain = domain.tld
↓
mydomain = crimson-snow.net <= ドメイン名を指定

#myorigin = $mydomain
↓
myorigin = $mydomain <= コメント解除( @ 以下のアドレス)

メールを受け取る範囲を指定する
#inet_interfaces = all
↓
inet_interfaces = all <= コメント解除

自ホストが最終的な宛先とみなすアドレスの変更
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
↓
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain <= コメント解除

#mynetworks = 168.100.189.0/28, 127.0.0.0/8
↓
mynetworks = 192.168.0.0/16, 127.0.0.0/8 <= 変更(LANのアドレスとローカルホストアドレスを指定)

エイリアスの設定
#alias_maps = dbm:/etc/aliases
↓
alias_maps = dbm:/etc/aliases <= コメント解除

#alias_database = dbm:/etc/aliases
↓
alias_database = dbm:/etc/aliases <= コメント解除


#home_mailbox = Maildir/
↓
home_mailbox = Maildir/ <= コメント解除(メールボックスをmaildir形式に変更)

#smtpd_banner = $myhostname ESMTP $mail_name
↓
smtpd_banner = mail.$mydomain ESMTP $mail_name <= サーバ情報の表示を変更

root宛てのメールを一般ユーザに転送します。

Solaris# mv /etc/aliases.org /etc/aliases <= バックアップしていたエイリアスファイルをリネーム
Solaris# vi /etc/aliases
root:		kaz <= 追加(一般ユーザ kaz に転送)


Solaris# newaliases <= aliasesの読み込み
ヘッダの書き換え

ヘッダにあるLANの情報を削除します。

main.cfの設定

Solaris# vi /etc/postfix/main.cf <= 設定ファイルの編集
#header_checks = regexp:/etc/postfix/header_checks
↓
header_checks = regexp:/etc/postfix/header_checks <= コメント解除

header_checksの設定

Solaris# vi /etc/postfix/header_checks <= 設定ファイルの編集
/^Received:.*192\.168\..*/ IGNORE <= 追加
/^Received:.*127\.0\.0\.1.*/ IGNORE <= 追加
「Postfix」の起動
Solaris# /usr/sbin/postfix start

「Postfix」の自動起動

「Postfix」用の起動スクリプトを作成し、ランレベル2,3の時に自動起動するようにします。

Solaris# vi /etc/init.d/postfix <= 起動スクリプトファイルの作成
#!/sbin/sh

PID=`/usr/bin/ps -aef | /usr/bin/grep postfix | /usr/bin/grep master | /usr/bin/grep -v grep | /usr/bin/awk '{print $2}'`

case "$1" in
'start')
        if [ -f /usr/sbin/postfix ]; then
                if [ $PID ]; then
                        echo "Postfix has started"
                else
                        /usr/sbin/postfix start
                        echo "Running: Postfix"
                fi
        fi
        ;;

'stop')
        if [ $PID ]; then
                /usr/sbin/postfix stop
                echo "Stopping: Postfix"
        else
                echo "Postfix has stopped"
        fi
        ;;

'reload')
        /usr/sbin/postfix reload
        ;;

'abort')
        /usr/sbin/postfix abort
        ;;

'flush')
        /usr/sbin/postfix flush
        ;;

'status')
        if [ $PID ]; then
                echo "Postfix starts"
        else
                echo "Postfix stopped"
        fi
        ;;

*)
        echo "Usage: $0 {start|stop|reload|abort|flush|status}"
        exit 1
        ;;

esac
exit 0


Solaris# chmod 744 /etc/init.d/postfix <= 起動スクリプトに実行権限付加
Solaris# ln /etc/init.d/postfix /etc/rc2.d/S88postfix <= ランレベル2で起動する
Solaris# ln /etc/init.d/postfix /etc/rc3.d/S88postfix <= ランレベル3で起動する
Solaris# ln /etc/init.d/postfix /etc/rc0.d/K36postfix <= ランレベル0で停止する
▲ページのトップへ