2007年 6月 26日 火曜日
やっぱり Sun がスキ!
Sun Java System Messaging Server でスマートホストを指定しよう
外部に向けてメールを送る際、ウィルススキャンを実行するサーバや、 フィルタリングを実行するサーバを必ず通したいと思った事はありませんか?
また、DMZ の内側から外向けのメール配信が許可されているサーバを必ず 通したいと思った事はありませんか?
今回は Sun Java System Messaging Server (以下 SJS MS) にて、 配信されるメールを特定の MTA(スマートホスト) に ルーティングさせる機能の設定を行ってみます。
SJS MS の MTA には、複数の SMTP チャネルがあります。
- tcp_local : メッセージの受信、リモート SMTP ホストへの送信を行います。 - tcp_intranet : イントラネット内のメッセージを送受信します。 - tcp_auth : smtp auth によって認証されたメッセージを送受信します。 - tcp_submit : port 587 にて送信されたメッセージを受け入れます。 - tcp_tas : Unified Messaging を使用するサイト用の特殊な IA チャネル。
SJS MS では、各チャネルに対する設定を行う事で、配信時の動作を変更する事が出来ます。
具体的には、/opt/SUNWmsgsr/config/imta.cnf ファイル内の "! part II : channel blocks" 以降に記載されている各チャネルに、チャネルキーワードを指定する事で、動作を決める事が出来ます。
今回は、外部 MTA へメッセージを配信する際に通常使用される tcp_local チャネルが対象になります。
チャネルキーワードのドキュメントを確認すると、スマートホストの指定は、daemon キーワードでターゲットホストを指定すれば出来そうです。
では早速、tcp_local チャネルに daemon キーワードを追加してスマート ホストを指定してみましょう。
tcp_local smtp mx daemon smarthost.jestest.com single_sys master_debug remotehost inner switchchannel identnonenumeric subdirs 20 maxjobs 7 pool SMTP_POOL maytlsserver maysaslserver saslswitchchannel tcp_auth missingrecipientpolicy 0 ※ 1 行で記述する必要があります。
また、今回は、正しく動作しているのかを確認する為に、master_debug キーワードも追加しました。
この記述が出来たら以下のコマンドで、コンフィグの再認識・ SJS MS の再起動を実行しましょう。
# /opt/SUNWmsgsr/sbin/imsimta cnbuild # /opt/SUNWmsgsr/sbin/imsimta restart
それではテストしてみましょう。
% telnet mta 25 Trying XXX.XXX.XXX.XXX... Connected to mta.jestest.com. Escape character is '^]'. 220 mta -- Server ESMTP (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005)) helo mta 250 mta OK, [XXX.XXX.XXX.XXX]. mail from:250 2.5.0 Address Ok. rcpt to: 250 2.1.5 hoge.hoge@Sun.COM OK. data 354 Enter mail, end with a single ".". To: hoge.hoge@Sun.COM From: test@jestest.com Subject: test test hoge . 250 2.5.0 Ok. quit
上記でテストメールを送ったら、debug log ファイルを見てみましょう。
% ls -t /var/opt/SUNWmsgsr/log | head tcp_local_master.log-0JJW00603XLAU600 tcp_local_master.log-f0B2w0f_3s0 tcp_local_master.log-f0B2w0d_kd0 tcp_local_master.log-f0B2w0d_kb0 http pop imap tcp_local_master.log-0JJW00603X96TR00 job_controller.log-0JJW00601X95TL00 tcp_smtp_server.log-0JJW00602X94TK00 % more /var/opt/SUNWmsgsr/log/tcp_local_master.log-0JJW00603XLAU600 11:29:34.26: Initializing message dequeue via quc_rinit, file "/opt/SUNWmsgsr/data/queue/tcp_local/009/ZZf0B2w0f_3_2.01" 11:29:34.26: Reading first To: address 11:29:34.26: Forced routing to smarthost.jestest.com 11:29:34.26: Setting up connection to "smarthost.jestest.com", initial mailbox "hoge.hoge" 11:29:34.26: No connection currently open 11:29:34.26: Opening new connection for smarthost.jestest.com 11:29:34.26: MX lookup: Looking up MX records for smarthost.jestest.com 11:29:34.27: MX lookup: res_send failed 11:29:34.27: Error: Connection refused 11:29:34.27: Preparing log entry 11:29:34.27: Calling log_connection_info 11:29:34.27: log_connection_info returned 11:29:34.27: Recording temporary connection failure in local cache 11:29:34.27: Status code = 136 11:29:34.27: Unable to connect to host, cannot dequeue 11:29:34.28: Shutting down message dequeue and any open connections
どうやら、smarthost.jestest.com から、DNS の MX レコードを探して 失敗しているようです。
今回は、直接 smarthost.jestest.com に配信して貰いたいので、MX レコードを探されては困ります。
そこで、先ほどのチャネル設定を見直してみましょう。
tcp_local smtp mx daemon smarthost.jestest.com single_sys master_debug remotehost inner switchchannel identnonenumeric subdirs 20 maxjobs 7 pool SMTP_POOL maytlsserver maysaslserver saslswitchchannel tcp_auth missingrecipientpolicy 0
なにやら、mx というキーワードがあります。
このキーワードを確認すると、MX レコードを確認する設定の様です。
それでは、MX レコードを確認しないように、nomx キーワードに変えて やってみます。
tcp_local smtp nomx daemon smarthost.jestest.com single_sys master_debug remotehost inner switchchannel identnonenumeric subdirs 20 maxjobs 7 pool SMTP_POOL maytlsserver maysaslserver saslswitchchannel tcp_auth missingrecipientpolicy 0
コンフィグを書き換えたら、再認識・リスタートを実施しましょう。
# /opt/SUNWmsgsr/sbin/imsimta cnbuild # /opt/SUNWmsgsr/sbin/imsimta restart
それでは再度テストします。
% telnet mta 25 Trying XXX.XXX.XXX.XXX... Connected to mta.jestest.com. Escape character is '^]'. 220 mta -- Server ESMTP (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005)) helo mta 250 mta OK, [XXX.XXX.XXX.XXX]. mail from:250 2.5.0 Address Ok. rcpt to: 250 2.1.5 hoge.hoge@Sun.COM OK. data 354 Enter mail, end with a single ".". To: hoge.hoge@Sun.COM From: test@jestest.com Subject: test test hoge . 250 2.5.0 Ok. quit
ログを確認
% ls -t /var/opt/SUNWmsgsr/log | head tcp_local_master.log-0JJW00603XVXV300 tcp_local_master.log-f0B2w0g_sZ0 tcp_local_master.log-0JJW00603XVEV200 tcp_local_master.log-f0B2w0g_sY0 job_controller.log-0JJW00601XVCUV00 tcp_smtp_server.log-0JJW00602XVCUW00 tcp_smtp_server.log-0JJW00602XVCUU00 dispatcher.log-0JJW00601XVCUS00 tcp_local_master.log-f0B2w0f_3s0 http % more /var/opt/SUNWmsgsr/log/tcp_local_master.log-0JJW00603XVXV300 11:35:57.20: Initializing message dequeue via quc_rinit, file "/opt/SUNWmsgsr/data/queue/tcp_local/018/ZZf0B2w0g_xU0.00" 11:35:57.20: Reading first To: address 11:35:57.20: Forced routing to smarthost.jestest.com 11:35:57.20: Setting up connection to "smarthost.jestest.com", initial mailbox "hoge.hoge" 11:35:57.20: No connection currently open 11:35:57.20: Opening new connection for smarthost.jestest.com 11:35:57.20: No MX lookup done 11:35:57.20: os_smtp_open: Connecting to smarthost.jestest.com 11:35:57.20: TCP active open: Trying to connect to "IP Address of smarthost.jestest.com" 11:35:57.21: smtp_open to smarthost.jestest.com returned 9 11:35:57.21: Reading initial status line from remote server... 11:35:57.21: Got status : "220 smarthost.jestest.com ESMTP server ready Wed, 20 Jun 2007 11:35:57 +0900" 11:35:57.22: Starting SMTP dialogue 11:35:57.22: Sending : "EHLO mta" 11:35:57.22: Got status : "250-smarthost.jestest.com" 11:35:57.22: Got EHLO options: 11:35:57.22: - - - - - - - - - - - - 11:35:57.22: SIZE=20971520 11:35:57.22: 8BITMIME= 11:35:57.22: DSN= 11:35:57.22: PIPELINING= 11:35:57.22: - - - - - - - - - - - - 11:35:57.22: DSN extension found 11:35:57.22: DSN originator notifications can be passed along 11:35:57.22: Sending : "MAIL FROM:SIZE=1024 11:35:57.22: DSN recipient notifications can be passed along 11:35:57.22: Sending : "RCPT TO: NOTIFY=FAILURE,DELAY 11:35:57.22: Sending : "DATA" 11:35:57.23: Got status : "250 Sender and extensions (SIZE=1024) Ok" 11:35:57.23: Got status : "250 Recipient and extensions (NOTIFY=FAILURE,DELAY) Ok" 11:35:57.23: Got status : "354 Ok Send data ending with . " 11:35:57.23: Write message header/body in one go 11:35:57.23: ... Message header/body, 14 lines ... 11:35:57.23: Sending : "." 11:35:58.85: Got status : "250 Message received: 20070620023557.TTDD13118.smarthost.jestest.com@mta" 11:35:58.85: Shutting down message dequeue and any open connections 11:35:58.85: Shut down SMTP with QUIT command 11:35:58.85: Sending : "QUIT" 11:35:58.86: Got status : "221 smarthost.jestest.com ESMTP server closing connection" 11:35:58.86: Closing SMTP channel 11:35:58.86: smtp_pmt_close: [0x0000000a] status 0
これで正しくスマートホストに配信されている事が確認出来ました。
最後に debug 出力を解除しましょう。
tcp_local smtp nomx daemon smarthost.jestest.com single_sys remotehost inner switchchannel identnonenumeric subdirs 20 maxjobs 7 pool SMTP_POOL maytlsserver maysaslserver saslswitchchannel tcp_auth missingrecipientpolicy 0
毎度の事ですが、再認識・リスタートを実施しましょう。
# /opt/SUNWmsgsr/sbin/imsimta cnbuild # /opt/SUNWmsgsr/sbin/imsimta restart
これでスマートホストの設定が完了しました。
* 参考ドキュメント
Sun Java System Messaging Server 6 2005Q4 管理ガイド -> 8. MTA の概念 -> チャネル Sun Java System Messaging Server 6 2005Q4 管理ガイド -> 12. チャネル定義を設定する -> SMTP チャネルを設定する -> 表 12-20 SMTP チャネル Sun Java System Messaging Server 6 2005Q4 管理ガイド -> 12. チャネル定義を設定する -> 機能別チャネルキーワード Sun Java System Messaging Server 6 2005Q4 管理ガイド -> 12. チャネル定義を設定する -> SMTP チャネルを設定する -> ターゲットホストの選択
* Where to Start
機能検証などの為にとりあえずインストールしてみようという方には、 以下のドキュメントがおすすめです。
簡単な手順で SJS MS の環境が作成出来ます。
Deployment Example: Sun Java Communications Suite 5 on a Single Host
また、今すぐ Sun のメールサーバを試してみたいという方は、以下の場所 から無償でダウンロード可能です。
Solaris (x86/SPARC)版に限らず、Linux 版もありますので、 是非お試し下さい。
Product Downloads -> Sun Java Communications Suite 5
※ ちなみに Download Center の利用には登録が必要になりますが、 登録にもお金はかかりません。
Posted at 04:15午後 6 26, 2007 by Naoyuki Yamada in Sun | 投稿されたコメント[0]
投稿されたコメント: