SlideShare a Scribd company logo
1 of 28
Download to read offline
Linux Server Admin


    Mail Systems

    Chatchai J
    2012-12-11
    2012-12-24
    2012-12-26
Mail Systems




 Picture from wikipedia
http://upload.wikimedia.org/wikipedia/commons/thumb/7/72/Email.svg/400px-Email.svg.png
Mail Systems
●   การรับ/ส่ง e-mail กระบวนค่อนข้างซับซ้อน

    –   ถ้าสนใจลองอ่านจาก wikipedia: “Email”

●   เราจะสนใจเฉพาะ ส่วนทีสำาคัญ
                         ่

    –   Server สำาหรับการ รับ/ส่ง mail
        (Computer ↔ Computer)
    –   Server สำาหรับติดต่อผ้้ใช้ (Computer ↔ User)
Mail Servers
●   SMTP Server
    –   รับ mail message จากผ้ใช้
                              ้

    –   รับ/ส่ง mail message จาก SMTP Server อื่น
●   IMAP/POP3 Server
    –   รับ mail จาก mailbox/storage ให้ user
SMTP Server
●   Simple Mail Transfer Protocol Server
    (Simple!)
●   มีหลายตัวเลือก
    –   postfix
    –   exim
    –   sendmail
    –   …
●   Debian ใช้ default smtp server เป็ น exim4
IMAP/POP3 Server
●   Internet Message Access Protocol
    Post Office Protocol (version 3)
●   สำาหรับ mail reader เข้าถึง mailbox ของผ้้ใช้

●   มีหลายตัวเลือกเช่นกัน
    –   uw-imap (Woshington Univ)
    –   cyrus-imapd (Cyrus Mail Systems)
    –   dovecot
●   ใช้ Dovecot เพราะรองรับ Maildir format
Exim4
●   ติดตั้งเป็ น default smtp อย่้แล้ว

    –   แต่ config ให้รับเฉพาะ local อย่างเดียว

●   ทดสอบ
        $ echo test | mail ­s test `whoami`
        $ mail
        หรือ
        $ mutt
Exim4 (cont)
●   ด้หมายเลข IP ปั จจุบัน
    $ /sbin/ifconfig | grep 'inet ' | grep ­v 127.0.0.1

●   กำาหนดค่าให้กับตัวแปรของ shell ชื่อ IP
    $ IP=`/sbin/ifconfig | grep 'inet ' | head ­1 | cut ­f2 ­d: | cut 
    ­f1 ­d' '`

●   ในบรรทัดที่แล้ว คำาสั่งอย่้ในบรรทัดเดียว

●   ใช้ backtick (คีย์ ` ใต้ ESC ใต้อักษร '~')
    สำาหรับคร่อมคำาสั่งทั้งหมด
Exim4 (cont)
●   ทดสอบ
    $ nc $IP 25
    $ nc 127.0.0.1 25
●   ใช้ $IP ควรจะติดต่อไม่ได้ เพราะยังไม่ได้ กำาหนด config
    ของ exim ให้เป็ นแบบ internet

●   ใช้ 127.0.0.1 จะใช้งานได้ เพราะ config เป็ น local

●   ใช้ CTRL-C สำาหรับ exit จาก nc
Exim4 config
●   ไฟล์ simplify config
    /etc/exim4/update-exim4.conf.conf
    ใช้ editor แก้ไข หรือ ใช้คำาสั่ง
    $ sudo dpkg­reconfigure exim4­config
●   config ที่ต้องแก้
    dc_eximconfig_configtype='local'
    dc_local_interfaces='127.0.0.1 ; ::1'

●   และ ควรจจะแก้
    dc_use_split_config='false'
    dc_localdelivery='mail_spool'
Exim4 config (cont)
●   config ที่ต้องแก้
    dc_eximconfig_configtype='internet'
    dc_local_interfaces=''
    dc_use_split_config='true'
    dc_localdelivery='maildir_home'

●   config อื่น
    dc_other_hostnames='$YOURDOMAIN'
    dc_other_hostnames='cheshirecat2012.net'
Exim4 config ** เพิ่ม **(cont)
●   สำาหรับ Exim4 Server ซึ่ งมี ip address อย่ใน
                                               ้
    private address (10.0.0.0/8, 192.168.0.0/16, 
    172.16.0.0/12) จะต้องแก้ไข router config ในไฟล์

    /etc/exim4/conf.d/router/200_exim4­
    config_primary
●   ให้ search หา dnslookup ซึ่ งจะมีลักษณะดังนี้
แก้ไข ignore_target_hosts จาก
dnslookup:
  debug_print = "R: dnslookup for $local_part@$domain"
  driver = dnslookup
  domains = ! +local_domains
  transport = remote_smtp
  same_domain_copy_routing = yes
  # ignore private rfc1918 and APIPA addresses
  ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 : 192.168.0.0/16 :
                       172.16.0.0/12 : 10.0.0.0/8 : 169.254.0.0/16 :
                       255.255.255.255
  no_more

.endif
แก้ ignore_target_hosts เป็ น
dnslookup:
  debug_print = "R: dnslookup for $local_part@$domain"
  driver = dnslookup
  domains = ! +local_domains
  transport = remote_smtp
  same_domain_copy_routing = yes
  # ignore private rfc1918 and APIPA addresses
  ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 : 255.255.255.255
  no_more

.endif
ทดสอบ new config
●   restart exim4
    $ sudo service exim4 restart

●   IP = หมายเลข IP ปั จจุบน
                           ั
    $ nc $IP 25
    $ nc 127.0.0.1 25

●   ควรจะใช้งานได้ท้ ังสองคำาสั่ง เพราะแก้ไข config ของ
    exim4 แล้ว

●   ต่อไปเป็ นการทดสอบการส่ง mail
ทดสอบส่ง mail
$ nc 172.30.3.25 25
220 lsa.coe.psu.ac.th ESMTP Exim 4.72 Wed, 12 Dec 2012 15:41:26 +0700
mail from: me@nowhere.now
250 OK
rcpt to: root@cheshirecat2012.net
250 Accepted
data
354 Enter message, ending with "." on a line by itself
Subject: test

test
.
250 OK id=1TihtT­00013z­AQ
quit
221 lsa.coe.psu.ac.th closing connection

ระบุช่ อ 'other_hostnames' ในส่วนของ email domain (cheshirecat2012.net)
       ื
ทดสอบ (ต่อ)
●   ตัวอย่างใน slide ที่แล้ว

    –   ตัวอักษรสีดำาเป็ น response ของคอมพิวเตอร์ / exim4

    –   ตัวอักษรสีน้ าเงิน/แดง เป็ นสิงที่เราจะต้องพิมพ์เข้าไป (ให้เปลี่ยน domain เป็ น
                     ำ                ่
        ของตนเอง)

●   email ผ้้รับ root@... อาจจะใช้ไม่ได้ ถ้าการ config user ยังไม่ถ้กต้อง ให้
    สร้าง user ธรรมดาขึ้นมารับ mail ก่อน

●   การส่งให้ root ระบบจะ forward ต่อให้ user ธรรมดา (ที่ทำาหน้าที่
    administrator) โดยการกำาหนดใน /etc/aliases
ทดสอบ (ต่อ)
●   ใช้คำาสั่ง mutt สำาหรับการอ่าน mail ทีส่งมา
                                          ่
    แล้วเก็บอย่ในระบบแบบ Maildir format
               ้

    –   bsd mailx อ่าน Maildir format ไม่ได้
        $ mutt ­f $HOME/Maildir
●   ด้ directory และ ไฟล์ใน $HOME/Maildir
        $ ls -l Maildir/{cur,new,tmp}
ทดสอบ SMTP Operation
●   การรับ/ส่ง email ระหว่าง SMTP Server กับ SMTP Server

●   ต้องการ Name Server Config ที่ถกต้อง
                                   ้

●   SMTP Server จะส่ง mail ไปยัง user@host.domain.com
    จะต้องร้้ IP Address ของ host.domain.com

●   SMTP Server จะส่ง mail ไปยัง user@domain.com
    จะต้องร้้ IP Address ของ Mail-Exchanger (MX) ของ
    domain.com
SMTP Operation (cont)
●   IP Address ของ smtp.cheshirecat2012.net
    $ host ­t a smtp.cheshirecat2012.net

●   IP Address ของ MX ของ cheshirecat2012.net
    $ host ­t mx cheshirecat2012.net
    $ host ­t a mx.cheshirecat2012.net

●   จะต้อง config ใน DNS ให้ถ้กต้อง
    และกำาหนด dnscache ให้ใช้ lsa-svr.coe.psu.ac.th
    – สำาหรับกรณีทดลองจาก CoE'NEt (เท่านั้น)
zone new config
$TTL 240

...

$ORIGIN    cheshirecat2012.net.
   IN NS   lsa­svr.coe.psu.ac.th.
   IN MX   5  mx.cheshirecat2012.net.
   IN MX   10 lsa­svr.coe.psu.ac.th.

smtp    30 IN   A   $IP
mx      30 IN   A   $IP
imap    30 IN   A   $IP
pop3    30 IN   A   $IP  
zone new config (cont)
●   เพิ่มข้อม้ลใน
    /var/cache/bind/master/$YOURDOMAIN
●   $IP คือ IP Address ของเครื่อง

●   บรรทัด
      IN MX 5 mx.$YOURDOMAIN
      IN MX 10 lsa­svr.coe.psu.ac.th

●   ค่า $YOURDOMAIN จะต้องน้อยกว่า ของ
    lsa-svr เพื่อให้ lsa-svr ส่งต่อไปยังปลายทางได้ถ้กต้อง
dnscache สำาหรับทดสอบ
●   ใช้ lsa-svr.coe.psu.ac.th เป็ น dnscache
●   file /etc/resolv.conf
    domain coe.psu.ac.th
    search coe.psu.ac.th
    nameserver 172.30.0.85

●   ใช้สำาหรับทดสอบจากภายใน CoE'Net เท่านั้น
ทดลองส่ง mail
●   ส่ง mail หา cj@cheshirecat2012.net
    $ echo “test” |
      mail ­s “This is a test” cj@cheshirecat2012.net

●   ผลการทำางานของ exim4 ด้ใน log
    /var/log/exim4/mainlog
    $ sudo tail ­f /var/log/exim4/mainlog
    $ sudo exigrep cheshirecat2012.net /var/log/exim4/mainlog
ทดลองส่ง mail (ต่อ)
●   ทดลองส่ง mail ถึง user ที่น่ งโต๊ะข้างๆ
                                 ั
    เพื่อความสะดวกให้สร้าง user ที่ช่ อว่า mailacct เพื่อง่ายต่อการทดสอบ
                                      ื

●   สร้าง mail account บนเครื่องตัวเอง
    $ sudo useradd ­m ­c “Mail Account” mailacct
    $ echo “mailacct:********” | sudo chpasswd

●   ส่ง mail หา mailacct บนเครื่องตัวเอง และเครื่องข้างๆ
    $ echo “`date`” | mail ­s test mailacct@$MYDOMAIN
    $ echo “`date`” | mail ­s test mailacct@$OTHERDOMAIN

●   Login โดยใช้ mailacct เพื่ออ่าน mail
    หลังจากใช้งานเสร็จแล้ว ก็ควร lock account mailacct โดยการใช้คำาสั่ง
    $ sudo passwd ­l mailacct
aliases
●   ไฟล์ /etc/aliases

●   สำาหรับสร้าง aliases กำาหนด email address ที่จะส่งต่อ

●   กำาหนด aliases default => root
    root: `whoami`
●   สามารถ copy หรือ forward ไป account อื่นๆได้

●   หรือแม้จะส่งให้กับ program อื่น
    โดยเฉพาะ procmail
/etc/aliases
●   e.g. บนเครื่องซึ่งเป็ น server ของ domain cheshirecat2012.net
    root: cj
    sysadm: cj@coe.psu.ac.th,  sysadmin@coe.psu.ac.th
    all: cj, mailacct
●   ส่ง email

    $ echo “test” | mail -s “Test” all@cheshirecat2012.net

    ส่งถึง cj กับ mailacct บน cheshirecat2012

●   ส่งถึง sysadm@cheshirecat2012.net จะถ้ก forward ต่อไปยัง
    cj, sysadmin ของ coe.psu.ac.th
คาบต่อไป (หลังสอบมิดเทอม?)
●   การ setup และใช้งาน IMAP & POP3 Server
●   procmail
●   fetchmail (อาจจะ)

●   spam filtering, โดยใช้ spamassassin และ
    greylist

More Related Content

What's hot (10)

Server2Go เว็บพกพาตัวจริง
Server2Go เว็บพกพาตัวจริงServer2Go เว็บพกพาตัวจริง
Server2Go เว็บพกพาตัวจริง
 
NETWORK SERVICEOPENSSH + NTP + SQUID
NETWORK SERVICEOPENSSH + NTP + SQUIDNETWORK SERVICEOPENSSH + NTP + SQUID
NETWORK SERVICEOPENSSH + NTP + SQUID
 
Basic linux
Basic linuxBasic linux
Basic linux
 
Ch15 elastic hosts-svradmin
Ch15 elastic hosts-svradminCh15 elastic hosts-svradmin
Ch15 elastic hosts-svradmin
 
Basic Linux
Basic LinuxBasic Linux
Basic Linux
 
Linux command-reference
Linux command-referenceLinux command-reference
Linux command-reference
 
Hotspotubuntu8
Hotspotubuntu8Hotspotubuntu8
Hotspotubuntu8
 
Linux diskless
Linux disklessLinux diskless
Linux diskless
 
Coovaubuntu904
Coovaubuntu904Coovaubuntu904
Coovaubuntu904
 
Proxy fc4 web
Proxy fc4 webProxy fc4 web
Proxy fc4 web
 

Viewers also liked

Building and Maintaining OpenSource Projects.
Building and Maintaining OpenSource Projects.Building and Maintaining OpenSource Projects.
Building and Maintaining OpenSource Projects.Akarawuth Tamrareang
 
Server Virtualization System and DR-Site / ระบบ Server Virtualization และ Dis...
Server Virtualization System and DR-Site / ระบบ Server Virtualization และ Dis...Server Virtualization System and DR-Site / ระบบ Server Virtualization และ Dis...
Server Virtualization System and DR-Site / ระบบ Server Virtualization และ Dis...Prakob Chantarakamnerd
 

Viewers also liked (6)

OPD System with ZK Grails
OPD System with ZK GrailsOPD System with ZK Grails
OPD System with ZK Grails
 
VBoxManage tutorial
VBoxManage tutorialVBoxManage tutorial
VBoxManage tutorial
 
Endian Firewall
Endian FirewallEndian Firewall
Endian Firewall
 
Building and Maintaining OpenSource Projects.
Building and Maintaining OpenSource Projects.Building and Maintaining OpenSource Projects.
Building and Maintaining OpenSource Projects.
 
Ch10 web servers
Ch10 web serversCh10 web servers
Ch10 web servers
 
Server Virtualization System and DR-Site / ระบบ Server Virtualization และ Dis...
Server Virtualization System and DR-Site / ระบบ Server Virtualization และ Dis...Server Virtualization System and DR-Site / ระบบ Server Virtualization และ Dis...
Server Virtualization System and DR-Site / ระบบ Server Virtualization และ Dis...
 

Similar to Ch08 mail-systems (15)

Ch12 web-app-part2
Ch12 web-app-part2Ch12 web-app-part2
Ch12 web-app-part2
 
Cent os
Cent osCent os
Cent os
 
Ch02 administrators-tasks
Ch02 administrators-tasksCh02 administrators-tasks
Ch02 administrators-tasks
 
Portable Moodle : Moodle & Server2Go
Portable Moodle  : Moodle & Server2GoPortable Moodle  : Moodle & Server2Go
Portable Moodle : Moodle & Server2Go
 
Linux diskless
Linux disklessLinux diskless
Linux diskless
 
Content cned model nakornsawan1
Content cned model nakornsawan1Content cned model nakornsawan1
Content cned model nakornsawan1
 
jMeter101
jMeter101jMeter101
jMeter101
 
Ubuntu office server-10.04-x64
Ubuntu office server-10.04-x64Ubuntu office server-10.04-x64
Ubuntu office server-10.04-x64
 
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05
 
ระบบ MS-DOS
ระบบ MS-DOSระบบ MS-DOS
ระบบ MS-DOS
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Ch17 secure-password
Ch17 secure-passwordCh17 secure-password
Ch17 secure-password
 
Docker 101 for developer
Docker 101 for developerDocker 101 for developer
Docker 101 for developer
 
คู่มือการติดตั้ง Cent os
คู่มือการติดตั้ง  Cent osคู่มือการติดตั้ง  Cent os
คู่มือการติดตั้ง Cent os
 
Assignment 1 of Database (MySQL & Sqlite3)
Assignment 1 of Database (MySQL & Sqlite3) Assignment 1 of Database (MySQL & Sqlite3)
Assignment 1 of Database (MySQL & Sqlite3)
 

Ch08 mail-systems

  • 1. Linux Server Admin Mail Systems Chatchai J 2012-12-11 2012-12-24 2012-12-26
  • 2. Mail Systems Picture from wikipedia http://upload.wikimedia.org/wikipedia/commons/thumb/7/72/Email.svg/400px-Email.svg.png
  • 3. Mail Systems ● การรับ/ส่ง e-mail กระบวนค่อนข้างซับซ้อน – ถ้าสนใจลองอ่านจาก wikipedia: “Email” ● เราจะสนใจเฉพาะ ส่วนทีสำาคัญ ่ – Server สำาหรับการ รับ/ส่ง mail (Computer ↔ Computer) – Server สำาหรับติดต่อผ้้ใช้ (Computer ↔ User)
  • 4. Mail Servers ● SMTP Server – รับ mail message จากผ้ใช้ ้ – รับ/ส่ง mail message จาก SMTP Server อื่น ● IMAP/POP3 Server – รับ mail จาก mailbox/storage ให้ user
  • 5. SMTP Server ● Simple Mail Transfer Protocol Server (Simple!) ● มีหลายตัวเลือก – postfix – exim – sendmail – … ● Debian ใช้ default smtp server เป็ น exim4
  • 6. IMAP/POP3 Server ● Internet Message Access Protocol Post Office Protocol (version 3) ● สำาหรับ mail reader เข้าถึง mailbox ของผ้้ใช้ ● มีหลายตัวเลือกเช่นกัน – uw-imap (Woshington Univ) – cyrus-imapd (Cyrus Mail Systems) – dovecot ● ใช้ Dovecot เพราะรองรับ Maildir format
  • 7. Exim4 ● ติดตั้งเป็ น default smtp อย่้แล้ว – แต่ config ให้รับเฉพาะ local อย่างเดียว ● ทดสอบ $ echo test | mail ­s test `whoami` $ mail หรือ $ mutt
  • 8. Exim4 (cont) ● ด้หมายเลข IP ปั จจุบัน $ /sbin/ifconfig | grep 'inet ' | grep ­v 127.0.0.1 ● กำาหนดค่าให้กับตัวแปรของ shell ชื่อ IP $ IP=`/sbin/ifconfig | grep 'inet ' | head ­1 | cut ­f2 ­d: | cut  ­f1 ­d' '` ● ในบรรทัดที่แล้ว คำาสั่งอย่้ในบรรทัดเดียว ● ใช้ backtick (คีย์ ` ใต้ ESC ใต้อักษร '~') สำาหรับคร่อมคำาสั่งทั้งหมด
  • 9. Exim4 (cont) ● ทดสอบ $ nc $IP 25 $ nc 127.0.0.1 25 ● ใช้ $IP ควรจะติดต่อไม่ได้ เพราะยังไม่ได้ กำาหนด config ของ exim ให้เป็ นแบบ internet ● ใช้ 127.0.0.1 จะใช้งานได้ เพราะ config เป็ น local ● ใช้ CTRL-C สำาหรับ exit จาก nc
  • 10. Exim4 config ● ไฟล์ simplify config /etc/exim4/update-exim4.conf.conf ใช้ editor แก้ไข หรือ ใช้คำาสั่ง $ sudo dpkg­reconfigure exim4­config ● config ที่ต้องแก้ dc_eximconfig_configtype='local' dc_local_interfaces='127.0.0.1 ; ::1' ● และ ควรจจะแก้ dc_use_split_config='false' dc_localdelivery='mail_spool'
  • 11. Exim4 config (cont) ● config ที่ต้องแก้ dc_eximconfig_configtype='internet' dc_local_interfaces='' dc_use_split_config='true' dc_localdelivery='maildir_home' ● config อื่น dc_other_hostnames='$YOURDOMAIN' dc_other_hostnames='cheshirecat2012.net'
  • 12. Exim4 config ** เพิ่ม **(cont) ● สำาหรับ Exim4 Server ซึ่ งมี ip address อย่ใน ้ private address (10.0.0.0/8, 192.168.0.0/16,  172.16.0.0/12) จะต้องแก้ไข router config ในไฟล์ /etc/exim4/conf.d/router/200_exim4­ config_primary ● ให้ search หา dnslookup ซึ่ งจะมีลักษณะดังนี้
  • 14. แก้ ignore_target_hosts เป็ น dnslookup:   debug_print = "R: dnslookup for $local_part@$domain"   driver = dnslookup   domains = ! +local_domains   transport = remote_smtp   same_domain_copy_routing = yes   # ignore private rfc1918 and APIPA addresses   ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 : 255.255.255.255   no_more .endif
  • 15. ทดสอบ new config ● restart exim4 $ sudo service exim4 restart ● IP = หมายเลข IP ปั จจุบน ั $ nc $IP 25 $ nc 127.0.0.1 25 ● ควรจะใช้งานได้ท้ ังสองคำาสั่ง เพราะแก้ไข config ของ exim4 แล้ว ● ต่อไปเป็ นการทดสอบการส่ง mail
  • 17. ทดสอบ (ต่อ) ● ตัวอย่างใน slide ที่แล้ว – ตัวอักษรสีดำาเป็ น response ของคอมพิวเตอร์ / exim4 – ตัวอักษรสีน้ าเงิน/แดง เป็ นสิงที่เราจะต้องพิมพ์เข้าไป (ให้เปลี่ยน domain เป็ น ำ ่ ของตนเอง) ● email ผ้้รับ root@... อาจจะใช้ไม่ได้ ถ้าการ config user ยังไม่ถ้กต้อง ให้ สร้าง user ธรรมดาขึ้นมารับ mail ก่อน ● การส่งให้ root ระบบจะ forward ต่อให้ user ธรรมดา (ที่ทำาหน้าที่ administrator) โดยการกำาหนดใน /etc/aliases
  • 18. ทดสอบ (ต่อ) ● ใช้คำาสั่ง mutt สำาหรับการอ่าน mail ทีส่งมา ่ แล้วเก็บอย่ในระบบแบบ Maildir format ้ – bsd mailx อ่าน Maildir format ไม่ได้ $ mutt ­f $HOME/Maildir ● ด้ directory และ ไฟล์ใน $HOME/Maildir $ ls -l Maildir/{cur,new,tmp}
  • 19. ทดสอบ SMTP Operation ● การรับ/ส่ง email ระหว่าง SMTP Server กับ SMTP Server ● ต้องการ Name Server Config ที่ถกต้อง ้ ● SMTP Server จะส่ง mail ไปยัง user@host.domain.com จะต้องร้้ IP Address ของ host.domain.com ● SMTP Server จะส่ง mail ไปยัง user@domain.com จะต้องร้้ IP Address ของ Mail-Exchanger (MX) ของ domain.com
  • 20. SMTP Operation (cont) ● IP Address ของ smtp.cheshirecat2012.net $ host ­t a smtp.cheshirecat2012.net ● IP Address ของ MX ของ cheshirecat2012.net $ host ­t mx cheshirecat2012.net $ host ­t a mx.cheshirecat2012.net ● จะต้อง config ใน DNS ให้ถ้กต้อง และกำาหนด dnscache ให้ใช้ lsa-svr.coe.psu.ac.th – สำาหรับกรณีทดลองจาก CoE'NEt (เท่านั้น)
  • 21. zone new config $TTL 240 ... $ORIGIN cheshirecat2012.net. IN NS lsa­svr.coe.psu.ac.th. IN MX 5  mx.cheshirecat2012.net. IN MX 10 lsa­svr.coe.psu.ac.th. smtp    30 IN A $IP mx      30 IN A $IP imap    30 IN A $IP pop3    30 IN A $IP  
  • 22. zone new config (cont) ● เพิ่มข้อม้ลใน /var/cache/bind/master/$YOURDOMAIN ● $IP คือ IP Address ของเครื่อง ● บรรทัด IN MX 5 mx.$YOURDOMAIN IN MX 10 lsa­svr.coe.psu.ac.th ● ค่า $YOURDOMAIN จะต้องน้อยกว่า ของ lsa-svr เพื่อให้ lsa-svr ส่งต่อไปยังปลายทางได้ถ้กต้อง
  • 23. dnscache สำาหรับทดสอบ ● ใช้ lsa-svr.coe.psu.ac.th เป็ น dnscache ● file /etc/resolv.conf domain coe.psu.ac.th search coe.psu.ac.th nameserver 172.30.0.85 ● ใช้สำาหรับทดสอบจากภายใน CoE'Net เท่านั้น
  • 24. ทดลองส่ง mail ● ส่ง mail หา cj@cheshirecat2012.net $ echo “test” |   mail ­s “This is a test” cj@cheshirecat2012.net ● ผลการทำางานของ exim4 ด้ใน log /var/log/exim4/mainlog $ sudo tail ­f /var/log/exim4/mainlog $ sudo exigrep cheshirecat2012.net /var/log/exim4/mainlog
  • 25. ทดลองส่ง mail (ต่อ) ● ทดลองส่ง mail ถึง user ที่น่ งโต๊ะข้างๆ ั เพื่อความสะดวกให้สร้าง user ที่ช่ อว่า mailacct เพื่อง่ายต่อการทดสอบ ื ● สร้าง mail account บนเครื่องตัวเอง $ sudo useradd ­m ­c “Mail Account” mailacct $ echo “mailacct:********” | sudo chpasswd ● ส่ง mail หา mailacct บนเครื่องตัวเอง และเครื่องข้างๆ $ echo “`date`” | mail ­s test mailacct@$MYDOMAIN $ echo “`date`” | mail ­s test mailacct@$OTHERDOMAIN ● Login โดยใช้ mailacct เพื่ออ่าน mail หลังจากใช้งานเสร็จแล้ว ก็ควร lock account mailacct โดยการใช้คำาสั่ง $ sudo passwd ­l mailacct
  • 26. aliases ● ไฟล์ /etc/aliases ● สำาหรับสร้าง aliases กำาหนด email address ที่จะส่งต่อ ● กำาหนด aliases default => root root: `whoami` ● สามารถ copy หรือ forward ไป account อื่นๆได้ ● หรือแม้จะส่งให้กับ program อื่น โดยเฉพาะ procmail
  • 27. /etc/aliases ● e.g. บนเครื่องซึ่งเป็ น server ของ domain cheshirecat2012.net root: cj sysadm: cj@coe.psu.ac.th,  sysadmin@coe.psu.ac.th all: cj, mailacct ● ส่ง email $ echo “test” | mail -s “Test” all@cheshirecat2012.net ส่งถึง cj กับ mailacct บน cheshirecat2012 ● ส่งถึง sysadm@cheshirecat2012.net จะถ้ก forward ต่อไปยัง cj, sysadmin ของ coe.psu.ac.th
  • 28. คาบต่อไป (หลังสอบมิดเทอม?) ● การ setup และใช้งาน IMAP & POP3 Server ● procmail ● fetchmail (อาจจะ) ● spam filtering, โดยใช้ spamassassin และ greylist