SERVEUR DE MESSAGERIE POSTFIX/ZIMBRA Philippe PHENGSAVATH 26/08/2011
SOMMAIRE I.INTRODUCTION...1 II.POSTFIX...2 II.1.Présentation...2 II.2.Installation de Postfix sous Debian...2 II.2.a.Modification de «hosts»...2 II.2.b.Installation de Postfix...2 II.2.c.Configuration de Postfix...3 II.2.d.Modification du fichier «main.cf»...3 II.2.e.Envoi d'un mail...4 II.2.f.Vérification des fichiers log...4 III.DOVECOT...6 III.1.Présentation...6 III.2.Installation de Dovecot sous Debian...6 III.3.Modification du fichier dovecot.conf...6 III.4.Création de fichiers...6 III.5.Modification des droits du répertoire Maildir...6 III.6.Redémarrage du service Dovecot...7 III.7.Vérification imap...7 III.8.Amavis...7 III.9.Anti-Spam...7 III.10.Clamav...7 III.11.WebMail...8 IV.ZIMBRA...10 IV.1.Installation de Zimbra sous Ubuntu...10 IV.1.a.Préparation à l'installation de Zimbra...10 IV.1.b.Installation de Zimbra...11 IV.1.c.Règles et routes statiques sur le firewall...13 IV.2.Interface Web Zimbra...13 V.CONCLUSION...15
I. INTRODUCTION Le but de ce TP est d'apprendre à installer un serveur de messagerie Postfix et Dovecot. Page 1 / 15
II. POSTFIX II.1. Présentation Postfix est un serveur de messagerie électronique et un logiciel libre développé par Wietse Venema et plusieurs contributeurs. Il se charge de la livraison de courriers électroniques (courriels) et a été conçu comme une alternative plus rapide, plus facile à administrer et plus sécurisée que l'historique Sendmail. II.2. Installation de Postfix sous Debian L'installation de Postfix se fera sur un Debian sans interface graphique. /etc# vi hosts II.2.a. Modification de «hosts» 127.0.0.1 localhost 172.25.205.2 mail.grp5.info-msj.net mail # 172.25.20x.2 et mail.grpx.info-msj.net où x est le numéro de groupe II.2.b. # apt-get install postfix Installation de Postfix Sélectionnez «Site Internet» puis «Ok» Configuration type du serveur de messagerie : Pas de configuration Site Internet Internet avec un «smarthost» Système satellite Local uniquement <Ok> <Annuler> Entrez «mail.grp5.info-msj.net» puis «Ok» Nom de courrier : mail.grp5.info-msj.net Page 2 / 15
<Ok> <Annuler> II.2.c. # dpkg-reconfigure postfix Configuration de Postfix Vérifiez que le type du serveur de messagerie et le nom de courrier soient bien entrés et que la taille maximale des boites aux lettres soit à 0. Pour le reste, laissez par défaut. Postfix Configuration Veuillez choisir la limite que Postfix mettra à la taille des boîtes aux lettres pour empêcher les erreurs de logiciels incontrôlables. Une valeur nulle signifie aucune limite. Les créateurs du logiciel utilisent une valeur par défaut de 51200000. Taille maximale des boîtes aux lettres (en octets) : 0 <Ok> <Annuler> II.2.d. Modification du fichier «main.cf» /etc/postfix# vi main.cf Modifiez comme ceci : myhostname = mail.grp5.info-msj.net mydomain = grp5.info-msj.net alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = $mydomain mydestination = $mydomain relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.25.205.0/24 home_mailbox = Maildir/ # mailbox_command = procmail -a "$EXTENSION" mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all inet_protocols = ipv4 Page 3 / 15
Redémarrez Postfix /etc/init.d#./postfix reload postfix/postfix-script: refreshing the Postfix mail system II.2.e. Tapez ceci : Envoi d'un mail ~# telnet localhost 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 mail.grp5.info-msj.net ESMTP Postfix (Debian/GNU) EHLO mail.dt5.info-msj.net 250-mail.grp5.info-msj.net 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN MAIL FROM:tsgeri@grp5.info-msj.net 250 2.1.0 Ok RCPT TO:tsgeri@grp5.info-msj.net 250 2.1.5 Ok DATA 354 End data with <CR><LF>.<CR><LF> test. 250 2.0.0 Ok: queued as C5816782A7 quit 221 2.0.0 Bye Connection closed by foreign host. II.2.f. Vérification des fichiers log Les fichiers log se trouvent dans le répertoire /var/log et se nomment mail.log, mail.err, mail.info et mail.warn. Vérification des log # egrep 'reject:' /var/log/mail.log Aug 2 09:23:12 DT13-1 postfix/smtpd[2922]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 550 5.1.1 <toto@grp5.info-msj.net>: Recipient address rejected: User Page 4 / 15
unknown in local recipient table; from=<tsgeri@grp5.info-msj.net> to=<toto@grp5.info-msj.net> proto=esmtp helo=<mail.dt5.info-msj.net> Aug 2 09:25:39 DT13-1 postfix/smtpd[2922]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 550 5.1.1 <tot@grp5.info-msj.net>: Recipient address rejected: User unknown in local recipient table; from=<tsgeri@grp5.info-msj.net> to=<tot@grp5.info-msj.net> proto=esmtp helo=<mail.grp5.info-msj.net> Aug 2 09:27:03 DT13-1 postfix/smtpd[2922]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 550 5.1.1 <toto@grp5.info-msj.net>: Recipient address rejected: User unknown in local recipient table; from=<tsgeri@grp5.info-msj.net> to=<toto@grp5.info-msj.net> proto=esmtp helo=<mail.grp5.info-msj.net> Aug 2 09:27:42 DT13-1 postfix/smtpd[2922]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 550 5.1.1 <dsn@grp5.info-msj.net>: Recipient address rejected: User unknown in local recipient table; from=<tsgeri@grp5.info-msj.net> to=<dsn@grp5.info-msj.net> proto=esmtp helo=<mail.grp5.info-msj.net> Aug 2 09:28:21 DT13-1 postfix/smtpd[2922]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 550 5.1.1 <DSN@grp5.info-msj.net>: Recipient address rejected: User unknown in local recipient table; from=<tsgeri@grp5.info-msj.net> to=<dsn@grp5.info-msj.net> proto=esmtp helo=<mail.grp5.info-msj.net> # egrep 'error:' /var/log/mail.log Aug 2 09:15:58 DT13-1 postfix/postfix-script[2882]: error: unknown command: 'restart' Aug 2 09:16:20 DT13-1 postfix/postfix-script[2902]: error: unknown command: 'restart' Aug 19 08:47:13 DT13-1 postfix/postfix-script[1288]: error: unknown command: '' # egrep 'fatal:' /var/log/mail.log Aug 2 09:15:58 DT13-1 postfix/postfix-script[2884]: fatal: usage: postfix start (or stop, reload, abort, flush, check, status, set-permissions, upgrade-configuration) Aug 2 09:16:20 DT13-1 postfix/postfix-script[2903]: fatal: usage: postfix start (or stop, reload, abort, flush, check, status, set-permissions, upgrade-configuration) Aug 19 08:46:44 DT13-1 postfix/postfix-script[1270]: fatal: the Postfix mail system is already running Aug 19 08:47:13 DT13-1 postfix/postfix-script[1289]: fatal: usage: postfix start (or stop, reload, abort, flush, check, status, set-permissions, upgrade-configuration) Page 5 / 15
III. DOVECOT III.1. Présentation Dovecot est un serveur IMAP et POP3 pour les systèmes d'exploitation Unix et dérivés, conçu avec comme premier but la sécurité. III.2. Installation de Dovecot sous Debian Installation de Dovecot common et imap # apt-get install dovecot-imapd dovecot-pop3d III.3. Modification du fichier dovecot.conf /etc/dovecot# vi dovecot.conf Modifiez les lignes suivantes : #login_greeting = Dovecot ready. login_greeting = Dovecot Serveur en service #mail_location = mail_location = maildir:/home/%u/maildir III.4. Création de fichiers # maildirmake.dovecot /etc/skel/maildir # maildirmake.dovecot /etc/skel/maildir/.drafts # maildirmake.dovecot /etc/skel/maildir/.sent # maildirmake.dovecot /etc/skel/maildir/.trash # maildirmake.dovecot /etc/skel/maildir/.templates /etc/skel/maildir# ls -a... cur.drafts new.sent.templates tmp.trash III.5. Modification des droits du répertoire Maildir # cp -r /etc/skel/maildir /home/tsgeri # chown -R tsgeri:tsgeri /home/tsgeri/maildir # chmod -R 700 /home/tsgeri/maildir /home/tsgeri/maildir# ls -a... cur.drafts new.sent.templates tmp.trash Page 6 / 15
/home/tsgeri# ls -l drwx------ 9 tsgeri tsgeri 4096 19 août 13:05 Maildir III.6. Redémarrage du service Dovecot /etc/init.d#./dovecot restart III.7. Vérification imap # telnet localhost imap Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE STARTTLS AUTH=PLAIN] Dovecot Serveur en service III.8. Amavis Installation d'amavis # apt-get install amavisd-new III.9. Anti-Spam Installation d'un anti-spam # apt-get install spamassassin Modifiez le fichier spamassassin /etc/default# vi spamassassin ENABLED=1 Relancez le service /etc/init.d#./spamassassin stop /etc/init.d#./spamassassin start III.10.Clamav Installation de Clamav # apt-get install clamav Page 7 / 15
III.11. WebMail Installation de Squirrelmail # apt-get install squirrelmail Copiez le fichier apache.conf # cp /etc/squirrelmail/apache.conf /etc/apache2/sites-available/squirrelmail Renommez les fichiers default et squirrelmail /etc/apache2/sites-available# mv default default.old /etc/apache2/sites-available# mv squirrelmail default Redémarrez le service apache2 /etc/init.d#./apache 2 restart Vérification par Web http://172.25.105.1/squirrelmail Entrez le «Name» et le «Password» Page 8 / 15
Page 9 / 15
IV. ZIMBRA IV.1. Installation de Zimbra sous Ubuntu L'installation de Ubuntu sous VMware se fera à partir d'un ISO du FTP TSGERI, sans graphique. Zimbra sera aussi téléchargé sur le FTP TSGERI en compressé, au format tgz. IV.1.a. Modification de Interfaces /etc/network# vi interfaces iface eth0 inet static address 172.25.105.11 netmask 255.255.255.0 gateway 172.25.105.254 nameserver '192.168.131.21' domain name 'grp5.info-msj.net' Préparation à l'installation de Zimbra Ajout d'informations sur le serveur DNS Windows Server 2008 Clic droit sur «GRP5.info-msj.net» de «Zones de recherche directes» (cf figure 1) Figure 1 Choisissez «Nouvel hôte» puis entrez le nom de l'ordinateur «Phil» et l'adresse IP «172.25.105.11», qui sont ceux de Ubuntu où sera installé Zimbra Cochez «Créer un pointeur d'enregistrement PTR associé» puis cliquez «Ajouter un hôte» Clic droit à nouveau sur «GRP5.info-msj.net» comme sur la figure 1 Choisissez «Nouveau serveur de messagerie» puis entrez l'hôte : Phil et cliquez sur Parcourir Sélectionnez l'hôte «Phil» et cliquez «OK» Cliquez «OK» Vérifiez que le pointeur d'enregistrement PTR a bien été créé en allant sur «105.25.172.inaddr.arpa» (cf figure 2) Page 10 / 15
Figure 2 Séléctionnez «105.25.172.in-addr.arpa» et vérifiez que l'adresse IP «172.25.105.11» contenant le nom de l'hôte «Phil» est présent dans la fenêtre de droite. S'il ne se trouve pas, faites un clic droit sur «105.25.172.in-addr.arpa» et choisissez «Nouveau pointeur» puis entrez l'adresse IP «172.25.105.11» et le nom de l'hôte «Phil» Cliquez «OK» Copie du fichier compressé Zimbra sur Ubuntu Sous SSH, allez sur «Window» => «New File Transfer» et téléchargez le fichier compressé Zimbra sur le serveur Ubuntu, dans /home/tsgeri Décompression du fichier compressé Zimbra /home/tsgeri# tar -zxvf zcs-7.1.2_ga_3268.ubuntu10_64.20110804130819.tgz Supression du fichier compressé Zimbra /home/tsgeri# rm zcs-7.1.2_ga_3268.ubuntu10_64.20110804130819.tgz IV.1.b. Installation de Zimbra /home/tsgeri# cd zcs-7.1.2_ga_3268.ubuntu10_64.20110804130819 /home/tsgeri#./install.sh L'installation se lance et lors de l'affichage de WARNING, annulez l'installation comme cidessous : ###WARNING### The suggested version of one or more packages is not installed. This could cause problems with the operation of Zimbra. Do you wish to continue? [N] n Page 11 / 15
Exit? [N] y Installation des composants manquants # apt-get install libpcre3 libgmp3c2 libstdc++6 sysstat libperl5.10 sqlite3 Relancez l'installation #./install.sh Select the packages to install Install zimbra-ldap [Y] y Install zimbra-logger [Y] y Install zimbra-mta [Y] y Install zimbra-snmp [Y] y Install zimbra-store [Y] y Install zimbra-apache [Y] y Install zimbra-spell [Y] y Install zimbra-memcached [N] n Install zimbra-proxy [N] n Checking required space for zimbra-core checking space for zimbra-store Installing: zimbra-core zimbra-ldap zimbra-logger zimbra-mta zimbra-snmp zimbra-store zimbra-apache zimbra-spell The system will be modified. Continue? [N] y Main menu Choisissez l'option 3 «zimbra-store» puis l'option 4 «Admin Password» et entrez un mot de passe. Revenez à l'écran principal de Main menu en tapant «r». Entrez «a» pour appliquer la modification puis «Yes» Appuyez sur «Entrée» à «Saving config in file...» puis entrez «y» pour continuer. Notify Zimbra of your installation? [Yes] n Configuration complete - press return to exit Page 12 / 15
IV.1.c. Règles et routes statiques sur le firewall Ajoutez une route statique sur le firewall pour chaque sous-réseau de groupe Règles LAN Règles WAN IV.2. Interface Web Zimbra Entrez l'adresse IP du serveur Ubuntu : http://172.25.105.11 et entrez l'utilisateur : admin et votre mot de passe admin. Page 13 / 15
Vérification du fonctionnement de Zimbra Page 14 / 15
V. CONCLUSION Une installation et configuration assez simples et rapides. Page 15 / 15