#author("2023-09-25T10:21:19+09:00","default:kuji","kuji") CONTENTS #contents ---- Lastmodified &lastmod; ---- *SMTP認証 [#sa8edd4a] 【参考URL】[[FreeBSD 12 で自宅サーバ作成 メールサーバ編:https://qiita.com/Chun3/items/dc0e176c9de4f6b4bfb8]]~ 【参考URL】[[Postfixのセキュリティ対策:https://www.criterion.sc/sub_notes/Postfix_Security.html]]~ 【参考URL】[[FreeBSD、Apacheでサーバを構築して公開する:http://hobbit.ddo.jp/html/bsd.html]] *cyrus-saslのインストール [#z2a3e92d] SMTP認証にsasl認証を使用する。 # portinstall security/cyrus-sasl2 # portinstall security/cyrus-sasl2-saslauthd /etc/rc.conf saslauthd_enable="YES" saslauthd_flags="-a sasldb" **saslauthd起動 [#sba0d34c] /usr/local/etc/rc.d/saslauthd start **SMTP AUTH設定 [#va7f222c] /usr/local/lib/sasl2/smtpd.conf pwcheck_method: auxprop 元記事はこうなっているが、現状、/usr/local/lib/sasl2/Sendmail.conf というファイルがあって、中身は pwcheck_method: auxprop となってて、同じ内様。両方設置しておくことにした。 **SMTP AUTHユーザー追加 [#y5e24553] # saslpasswd2 -c -u hobbit.ddo.jp user_name Password: Again (for verification): sasldblistusers2 user_name@hobbit.ddo.jp: userPassword * Postfix [#i229361a] BDB BLACKLISTD と SASL にチェック追加 #ref(Postfix_show_config.PNG) # portupgrade -rf --batch postfix **main.cf 設定 [#c8f2cc6e] myhostname = mail.smb.net # コメント解除でホスト名指定 mydomain = smb.net # コメント解除でドメイン名指定 myorigin = $myhostname # コメント解除(送信元メール) inet_interfaces = all # コメント解除(受信するネットワークアドレスを指定) mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain # コメント解除(ローカル配送先) mynetworks = 192.168.1.0/24, 127.0.0.0/8 # リレーを許可するIPアドレス relay_domains = $mydestination # コメント解除(リレーを許可するドメインを指定) alias_maps = hash:/etc/aliases # コメント解除(エイリアスを設定) alias_database = hash:/etc/aliases # コメント解除(エイリアスを設定) # Cyrus-SASL configuration # 下記を追加(SASLによるSMTP認証を使用) smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname smtpd_sasl_security_options = noanonymous smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination broken_sasl_auth_clients = yes *起動 [#c7766114] # service saslauthd start Starting saslauthd. # service postfix start postfix/postfix-script: starting the Postfix mail system *SMTP-AUTH の確認 [#ybe2857a] 【参考URL】[[Postfix で SMTP-AUTH を実現:http://www.miloweb.net/smtpauth.html]] SMTP-AUTH が正常に動作しているかを確認します。 具体的には Telnet で 25 番ポートにアクセスして確認します。 $ telnet localhost 25 <-- 入力し、エンター Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 www.miloweb.net ESMTP Postfix EHLO localhost <-- EHLO localhostと入力 250-zdnet.hoge.org 250-PIPELINING 250-SIZE 10240000 250-ETRN 250-AUTH SCRAM-SHA-512 SCRAM-SHA-384 SCRAM-SHA-256 SCRAM-SHA-224 SCRAM-SHA-1 DIGEST-MD5 CRAM-MD5 NTLM LOGIN PLAIN 250-AUTH=SCRAM-SHA-512 SCRAM-SHA-384 SCRAM-SHA-256 SCRAM-SHA-224 SCRAM-SHA-1 DIGEST-MD5 CRAM-MD5 NTLM LOGIN PLAIN <-- この行があればオッケーです 250 8BITMIME QUIT <-- 確認できたので、QUITコマンドで切断します もし「 250-AUTH PLAIN LOGIN 」と表示されていれば、SMTP-AUTH が上手く行っていないので、 Postfix のインストール手順を見直して、やり直さなければならない。 ---- Total access &counter(total);:本日 &counter(today);:昨日 &counter(yesterday); #counter([total|today|yesterday]);