1 / 27

メールサーバー

メールサーバー. 牧之内研究室 05/12/26 二反田 慎. メールサーバの仕組み. SMTP と POP. SMTP (simple mail transfer protocol) ドメイン名からホストの IP アドレスを調べ、         TCP 通信ルートを確立 POP (post office protocol) 受信サーバー接続時にメールを受け取る方法 POP 認証( POP Before SMTP ) SMTP サーバを利用してメールを送信する前に               メール受信 (POP) によりユーザ認証.

duman
Télécharger la présentation

メールサーバー

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. メールサーバー 牧之内研究室 05/12/26 二反田 慎

  2. メールサーバの仕組み

  3. SMTPとPOP • SMTP (simple mail transfer protocol) • ドメイン名からホストのIPアドレスを調べ、        TCP通信ルートを確立 • POP (post office protocol) • 受信サーバー接続時にメールを受け取る方法 • POP認証(POP Before SMTP) • SMTPサーバを利用してメールを送信する前に               メール受信(POP)によりユーザ認証 ○○○@ △△△.×××.jp ドメイン名

  4. メール配送の仕組み メールサーバ メールサーバ POPサーバ POPサーバ POP POP SMTPサーバ SMTPサーバ SMTP SMTP SMTP クライアント クライアント サーバのIPアドレス 問い合わせ ・SMTPでメール送信 ・POPでメール受信 DNSサーバ DNSサーバ

  5. DNSサーバに登録 ※dnsmailのdb.zoneの例 @ IN SOA dnsmail.db.is.kyushu-u.ac.jp. kaneko.db.is.kyushu-u.ac.jp. ( 2005102701 ; Serial 3600 ; Refresh (1 hour) 1200 ; Retry (20 minutes) 3600000 ; Expire (1000 hours) 86400 ; Minimum TTL (1 day) ) db.is.kyushu-u.ac.jp. IN NS dnsmail.db.is.kyushu-u.ac.jp. db.is.kyushu-u.ac.jp. IN MX 10 dnsmail.db.is.kyushu-u.ac.jp. dnsmail IN A 133.5.18.160 : 宛先ドメイン名 FQDN

  6. sendmailとqmail • sendmail • Unix の標準的なメールサーバソフトウェア • qmail • 安定で安全なメールサーバソフトウェア • 設定が簡単 ・設定が複雑 ・セキュリティ上の問題がなくならない

  7. sendmailで構築

  8. sendmailでSMTPサーバ構築(1/4) • sendmail最新版のインストール • sendmailの設定 • 設定ファイルsendmail.cfの作成 • m4ツールで既存のfreebsd.mcを変換 # cd sendmail-8.12.10/cf/cf # cp /etc/mail/freebsd.mc freebsd.mc # ./Build /etc/mail/sendmail.cf 又は # m4 m4/cf.m4 /etc/mail/freebsd.mc > /etc/mail/sendmail.cf ※最小限の設定であり、詳細設定はfreebsd.mcの書き換えの必要有り

  9. sendmailでSMTPサーバ構築(2/4) • sendmailの自動起動(監視) • inetd.confの場合 • rc.confの場合 # vi /etc/inetd.conf ・smtp stream tcp nowait root /(tcpdへのパス)/tcpd /(sendmailへのパス)/sendmail -bs –oq # vi /etc/rc.conf ・inetd_enable="YES" # vi /etc/rc.conf ・sendmail_enable="YES" ・sendmail_flags="-bd -q30m"

  10. sendmailでSMTPサーバ構築(3/4) • sendmailの動作確認 # sendmail –bt –C sendmail >$m ⇒ドメイン名が正しいか >$w ⇒ホスト名の定義 >/mx nitanda.local.db.is.kyushu-u.ac.jp ⇒MXとの整合性 >0 nitanda@nitanda.local.db.is.kyushu-u.ac.jp ⇒メールユーザーとして認識されるかどうか

  11. sendmailでSMTPサーバ構築(4/4) • SMTPポート経由でsendmailの確認 # telnet localhost smtp Trying 127.0.0.1...Connected to localhost.Escape character is ‘^]’.

  12. qpopperでpopサーバ構築(1/2) • popのアカウントを作成 • qpopperのインストール • qpopperの設定(inetdから起動させる) # vipw ・pop:*:68:1::0:0:Post Office Owner:/nonexistent:/nonexistent # vi /etc/inetd.conf ・pop stream tcp nowait root /(popperへのパス)/popperpopper # vi /etc/rc.conf ・inetd_enable="YES"

  13. qpopperでpopサーバ構築(2/2) • POP3ポート経由でsendmailの確認 # telnet localhost pop3 Trying 127.0.0.1...Connected to localhost.Escape character is ‘^]’.(入力) 220 localhost.localdomain ESMTP Sendmail ・・・

  14. メール送受信テスト • ユーザnitanda宛てにメール送信 • 受信確認 # mail nitanda@nitanda.local.db.is.kyushu-u.ac.jp Subject: TEST ⇒題目 Test . ⇒ピリオドで本文終了 Cc: (return) # mail : ⇒リスト表示 &1 ⇒見たいメールの番号指定 : ⇒本文表示

  15. qmailで構築

  16. qmailでSMTPサーバ構築(1/3) • sendmailの停止 • qmailを動作させるユーザとグループ作成 # vipw alias:*:7790:2108::0:0::/var/qmail/alias:/sbin/nologin qmaild:*:7791:2108::0:0::/nonexistent:/sbin/nologin qmaill:*:7792:2108::0:0::/nonexistent:/sbin/nologin qmailp:*:7793:2108::0:0::/nonexistent:/sbin/nologin qmailq:*:7794:2107::0:0::/nonexistent:/sbin/nologin qmailr:*:7795:2107::0:0::/nonexistent:/sbin/nologin qmails:*:7796:2107::0:0::/nonexistent:/sbin/nologin

  17. qmailでSMTPサーバ構築(2/3) • qmailインストール • qmailの設定 • 起動の為のスクリプト • 初期設定 # cd /var/qmail/configure/ # ./config-fast 受信するホスト名 # cp /var/qmail/boot/home /var/qmail/rc # vi /var/qmail/rc ⇒./Mailbox を ./Maildir/ に # vi /usr/local/etc/rc.d/qmail.sh ⇒./Mailbox を ./Maildir/ に

  18. qmailでSMTPサーバ構築(3/3) • ユーザが行う設定 • Maildir形式の使用を設定 • メールボックスの作成 % vi ~/.qmail ⇒先頭の行に ./Maildir/ と入力 % /var/qmail/bin/maildirmake Maildir

  19. qmail-vida • qmail-vida • SMTP認証とAPOP対応のPOP認証を追加 • バーチャルドメインと仮想ユーザを管理 ⇒APOPとSMTP認証のために導入 APOP・・・パスワードを暗号化したPOP

  20. qmail-vidaの導入() • 必要なユーザとグループの追加 groupadd vidauseradd -g vida popuseradd -g vida -s /bin/false authdbuseradd -g vida -s /bin/false qmailugroupadd nofilesuseradd -g nofiles -d /var/qmail -s /bin/false qmailduseradd -g nofiles -d /var/qmail -s /bin/false qmailluseradd -g nofiles -d /var/qmail -s /bin/false qmailpuseradd -g nofiles -d /var/qmail/alias -s /bin/false aliasgroupadd qmailuseradd -g qmail -d /var/qmail -s /bin/false qmailquseradd -g qmail -d /var/qmail -s /bin/false qmailruseradd -g qmail -d /var/qmail -s /bin/false qmails

  21. qmail-vidaの導入(1/4) • インストールとパッチ ①qmail-vida-0.53.tar.gz ⇒qmail と checkpassword へのパッチと メールアカウント管理プログラム②checkpassword-0.90.tar.gz ⇒checkpassword を CRAM-MD5 と APOP に 対応させて利用 ③ucspi-tcp-0.88.tar.gz ⇒tcpserver #cd qmail-vida-0.53 #make patch

  22. qmail-vidaの導入(2/4) • qmail-pop3d の起動スクリプト • checklocalpwd を checkpassword に変更 • pop3 コネクション用の tcpserver ルール     cdb 読み込みオプションを足す   : tcpserver -H -R -v -x /etc/service/tcp.pop3.cdb 0 pop3 qmail-popup $MYSVNAME \ checkpassword $MYPROGNAME Maildir 2>&1 | splogger pop3d &   :

  23. qmail-vidaの導入(3/4) • qmail-smtpdの起動スクリプト • qmail-smtpup という別個の認証部分のために設定 • PIDを書き出すdetectpidの調整   : tcpserver -H -R -v -x /etc/service/tcp.smtp.cdb 0 smtp \ rblsmtpd -r relays.ordb.org -r sbl.spamhaus.org -r dnsbl.ahbl.org \ qmail-smtpup $MYSVNAME checkpassword $MYPROGNAME 2>&1 | \ splogger smtpd &   : { detectpid smtp $TESTCHAR >$PIDFILE; } 2>/dev/null

  24. tcpserver経由でqmail起動(1/2) • メールの不正中継対策にtcpserverを導入(smtpを介してメール配送) • リレー設定 ※192.168.33.* と自分からのみ受け付ける # vi /etc/tcp.smtp 192.168.33.0-127:allow,RELAYCLIENT="" 127.:allow,RELAYCLIENT=""

  25. tcpserver経由でqmail起動(2/2) • リレー設定からデータベース作成 • qmaildのユーザIDとグループID確認 • 設定に基きtcpserver起動 # /usr/local/bin/tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp cdb・・・許可するホストのアクセス制御情報DB tmp・・・一時ファイル # id -u qmaild 82 # id -g qmaild 81 # tcpserver -u <ユーザID> -g <グループID> 0

  26. APOPサーバ導入(セキュリティ考慮) • APOP用ユーザ追加 • APOPインストール # vipw apopdb:*:7797:2107::0:0::/var/qmail/apopdb:/nonexistent

  27. qmailでメール送信 # /var/qmail/rc start # /var/qmail/bin/qmail-inject To : nitanda Subject: Test test (Ctrl+D) ※メールはユーザのMaildir以下のフォルダに配送

More Related