Postfix で SMTP AUTH

Debian (sarge) に苦労して、SMTP-AUTH対応にした。手順は簡単。

参考URL:
http://www.jimmy.co.at/weblog/?p=52

パッケージのインストール:

apt-get install postfix-tls sasl2-bin libsasl2 libsasl2-modules

/etc/default/saslauthd の編集:

START=yes
MECHANISMS="pam"

/etc/postfix/sasl/smtpd.conf を新規作成:

pwcheck_method: saslauthd

/etc/postfix/main.cf に以下の行を追加:

smtpd_sasl_auth_enable = yes
smtpd_sasl_exceptions_networks = $mynetworks
smtpd_recipient_restrictions = permit_mynetworks,
  permit_sasl_authenticated, reject_unauth_destination

上記の "smtpd_sasl_exceptions_networks" がポイント。$mynetworks は、SMTP AUTH しない。

postfix は、chroot 上で動作しているので、saslauthd と通信できるように
設定変更を行う:

rm -rf /var/run/saslauthd/
mkdir -p /var/spool/postfix/var/run/saslauthd
ln -s /var/spool/postfix/var/run/saslauthd /var/run/saslauthd
chgrp sasl /var/spool/postfix/var/run/saslauthd
adduser postfix sasl

postfix と saslauthd を再起動:

/etc/init.d/postfix restart
/etc/init.d/saslauthd start

その他の認証方法

http://espion.just-size.jp/archives/06/146170147.html
のように courier の認証機能を利用する手もある。
その場合の /etc/postfix/sasl/smtpd.conf :

pwcheck_method: authdaemond
authdaemond_path: /var/run/courier/authdaemon/socket
mech_list: plain login

BIND9 で再帰問合せのIP制限

options {
    (省略)
        allow-recursion {
            example-net;    #定義されたACLを用いた場合(none/any/localhost/localnetsを既定のACLとして利用することが可能)
            192.168.20.21;  #直接要求元のIPを指定した場合
            192.168.20.0/24;#ネットワーク単位で指定した場合
        };
    (省略)
};

acl example-net {
        192.168.20.21;
        192.168.20.0/24;
};