Postfix » Historique » Version 48
Patrice Nadeau, 2016-02-05 14:30
| 1 | 13 | Patrice Nadeau | h1. Postfix |
|---|---|---|---|
| 2 | 1 | Patrice Nadeau | |
| 3 | 12 | Patrice Nadeau | > Issue : #16 |
| 4 | |||
| 5 | 4 | Patrice Nadeau | http://www.postfix.org |
| 6 | 1 | Patrice Nadeau | |
| 7 | Logiciel de courrier électronique permettant, le transfert de courrier électronique (Message Transfert Agent). |
||
| 8 | |||
| 9 | Souvent installé de base pour l’envoie des message du serveur à une adresse externe. |
||
| 10 | 14 | Patrice Nadeau | |
| 11 | ---- |
||
| 12 | |||
| 13 | {{toc}} |
||
| 14 | |||
| 15 | 5 | Patrice Nadeau | Si le serveur doit envoyer et recevoir des messages de et vers l’Internet, les items suivant sont obligatoire : |
| 16 | * Domaine : Un nom de domaine enregistrer et sa gestion disponible |
||
| 17 | 1 | Patrice Nadeau | * MX records : pour permettre la réception de courriel. |
| 18 | 5 | Patrice Nadeau | * SPF records : pour permettre l’envoie de messages sans être bannis par les « reverse lookup ». |
| 19 | 1 | Patrice Nadeau | |
| 20 | 21 | Patrice Nadeau | Un serveur de relais (SMTP) externe seras nécessaire pour envoyer des courriels vers l’Internet si le port 25 est bloqué en entré (la majorité des cas). |
| 21 | 1 | Patrice Nadeau | |
| 22 | Les fichiers de configuration sont : |
||
| 23 | 5 | Patrice Nadeau | * _/etc/postfix/master.cf_ |
| 24 | * _/etc/postfix/main.cf_ |
||
| 25 | |||
| 26 | 13 | Patrice Nadeau | h2. Installation |
| 27 | 5 | Patrice Nadeau | |
| 28 | <pre><code class="bash"> |
||
| 29 | 48 | Patrice Nadeau | zypper install postfix perl-Mail-SPF |
| 30 | 15 | Patrice Nadeau | systemctl enable postfix |
| 31 | systemctl start postfix |
||
| 32 | 17 | Patrice Nadeau | # Ouvrir dans le pare-feu seulement si le serveur doit recevoir des courriels |
| 33 | 22 | Patrice Nadeau | yast firewall services add service=service:smtp zone=EXT |
| 34 | 5 | Patrice Nadeau | </code></pre> |
| 35 | |||
| 36 | 42 | Patrice Nadeau | h2. Configuration de base |
| 37 | 5 | Patrice Nadeau | |
| 38 | 21 | Patrice Nadeau | Si les courriels doivent sortir via un relais sur un autre serveur SMTP, modifier le fichier _/etc/postfix/main.cf_ : |
| 39 | 5 | Patrice Nadeau | <pre><code class="bash"> |
| 40 | # Inscrire votre serveur SMTP de sortie |
||
| 41 | relayhost = smtp_server |
||
| 42 | # Spécifier toutes les interfaces |
||
| 43 | inet_interfaces = all |
||
| 44 | # A la ligne mydestination, ajouter |
||
| 45 | $mydomain |
||
| 46 | # Permettre aux machines du réseau local, l'utilisation du serveur |
||
| 47 | smtpd_client_restrictions = permit_mynetworks |
||
| 48 | </code></pre> |
||
| 49 | > La ligne myhostname DOIT être la même que l’enregistrement DNS de type MX sur internet pour ce domaine. |
||
| 50 | 1 | Patrice Nadeau | |
| 51 | 13 | Patrice Nadeau | h2. Création de «blacklist» et de «whitelist». |
| 52 | 1 | Patrice Nadeau | |
| 53 | 6 | Patrice Nadeau | Informations provenant de : http://www.postfix.org/RESTRICTION_CLASS_README.html |
| 54 | 1 | Patrice Nadeau | |
| 55 | 6 | Patrice Nadeau | Fichier _/etc/postfix/main.cf_ |
| 56 | <pre><code class="bash"> |
||
| 57 | smtpd_recipient_restrictions = |
||
| 58 | check_sender_access hash: /etc/postfix/sender_access |
||
| 59 | </code></pre> |
||
| 60 | 1 | Patrice Nadeau | |
| 61 | 6 | Patrice Nadeau | Créer un fichier _/etc/postfix/sender_access_. |
| 62 | Placer à l’intérieur, l’adresse de courriel, le nom de domaine ou l’adresse IP avec l’une des options : |
||
| 63 | * OK |
||
| 64 | * REJECT |
||
| 65 | 1 | Patrice Nadeau | |
| 66 | 6 | Patrice Nadeau | Modifier le fichier _/etc/postfix/sender_access_ : |
| 67 | <pre><code class="bash"> |
||
| 68 | # myfriend.com OK |
||
| 69 | # myennemies.com REJECT |
||
| 70 | # myfriend@example.com OK |
||
| 71 | # junk@spam.com REJECT |
||
| 72 | # marketing@ REJECT |
||
| 73 | # theboss@ OK |
||
| 74 | # deals.marketing.com REJECT |
||
| 75 | # somedomain.com OK |
||
| 76 | 101.15.251.176 REJECT |
||
| 77 | </code></pre> |
||
| 78 | |||
| 79 | 7 | Patrice Nadeau | Relancer : |
| 80 | <pre><code class="bash"> |
||
| 81 | postmap /etc/postfix/sender_access |
||
| 82 | postfix reload |
||
| 83 | </code></pre> |
||
| 84 | |||
| 85 | 13 | Patrice Nadeau | h3. Utilisation de services de « blacklist » internet : |
| 86 | 7 | Patrice Nadeau | |
| 87 | Modifier le fichier _/etc/postfix/main.cf_ : |
||
| 88 | <pre><code class="bash"> |
||
| 89 | 29 | Patrice Nadeau | smtpd_recipient_restrictions = reject_rbl_client zen.spamhaus.org, reject_rhsbl_helo dbl.spamhaus.org, reject_rhsbl_sender dbl.spamhaus.org |
| 90 | </code></pre> |
||
| 91 | |||
| 92 | Relire la configuration |
||
| 93 | <pre><code class="bash"> |
||
| 94 | systemctl reload postix |
||
| 95 | 7 | Patrice Nadeau | </code></pre> |
| 96 | 6 | Patrice Nadeau | |
| 97 | 13 | Patrice Nadeau | h3. Alias |
| 98 | 10 | Patrice Nadeau | |
| 99 | 20 | Patrice Nadeau | Usagers systèmes devant être redirigé vers des comptes utilisateurs réel. |
| 100 | 10 | Patrice Nadeau | |
| 101 | 20 | Patrice Nadeau | Les ajouter dans le fichier _/etc/postfix/aliases_ |
| 102 | |||
| 103 | Lancer la commande _newaliases_ pour activer les changements. |
||
| 104 | |||
| 105 | 10 | Patrice Nadeau | |
| 106 | 13 | Patrice Nadeau | h3. Options courantes |
| 107 | 11 | Patrice Nadeau | |
| 108 | Dans _main.cf_ : |
||
| 109 | * *message_size_limit* : |
||
| 110 | |||
| 111 | 13 | Patrice Nadeau | h2. Entrés DNS |
| 112 | 6 | Patrice Nadeau | |
| 113 | 13 | Patrice Nadeau | h3. A record |
| 114 | 6 | Patrice Nadeau | |
| 115 | 13 | Patrice Nadeau | h3. MX record |
| 116 | 6 | Patrice Nadeau | |
| 117 | 13 | Patrice Nadeau | h3. SPF record |
| 118 | 6 | Patrice Nadeau | |
| 119 | 2 | Patrice Nadeau | Ajouter ceux du fournisseur internet (le fournisseur et et tous ses abonnées pourront "se faire passer" pour le domaine) |
| 120 | |||
| 121 | 13 | Patrice Nadeau | h2. Test |
| 122 | 2 | Patrice Nadeau | |
| 123 | 13 | Patrice Nadeau | h3. SPF |
| 124 | 3 | Patrice Nadeau | |
| 125 | Envoyer un courriel à une des adresses suivantes : |
||
| 126 | * check-auth@verifier.port25.com |
||
| 127 | 6 | Patrice Nadeau | * check-auth2@verifier.port25.com |
| 128 | 8 | Patrice Nadeau | |
| 129 | 43 | Patrice Nadeau | h2. TLS |
| 130 | 19 | Patrice Nadeau | |
| 131 | Site internet pour vérifier la configuration TLS : |
||
| 132 | * Envoie : https://www.checktls.com/perl/TestSender.pl |
||
| 133 | * Réception : https://www.checktls.com/perl/TestReceiver.pl |
||
| 134 | |||
| 135 | 37 | Patrice Nadeau | 2 paramètres sont utilisés : |
| 136 | * *smtp_tls_security_level* : En envoie vers un autre serveur SMTP |
||
| 137 | * *smtpd_tls_security_level* : En réception d'un client |
||
| 138 | |||
| 139 | Les valeurs suivantes peuvent être utilisées : |
||
| 140 | * *none* : TLs n'est pas utilisé |
||
| 141 | 45 | Patrice Nadeau | * *may* : TLS est utilisé/annoncé au client distant mais n'est pas obligatoire (Opportunistic) |
| 142 | 37 | Patrice Nadeau | * *encrypt* : TLS DOIT être utilisé. Selon le "RFC 2487":http://tools.ietf.org/html/rfc2487, cette option ne devrait pas être utilisée avec des serveur publiques. |
| 143 | |||
| 144 | 43 | Patrice Nadeau | h3. De Postfix vers un autre serveur SMTP |
| 145 | 31 | Patrice Nadeau | |
| 146 | 35 | Patrice Nadeau | Dans le fichier _/etc/postfix/mainc.cf_ |
| 147 | 1 | Patrice Nadeau | <pre><code class="bash"> |
| 148 | 35 | Patrice Nadeau | # Utilise l'encryption si disponible |
| 149 | smtp_tls_security_level = may |
||
| 150 | 45 | Patrice Nadeau | # Ajoute les messages TLS au journal |
| 151 | 35 | Patrice Nadeau | smtp_tls_loglevel = 1 |
| 152 | </code></pre> |
||
| 153 | 1 | Patrice Nadeau | |
| 154 | 47 | Patrice Nadeau | Dans le fichier _/etc/postfix/master.cf_, enlever le commentaire au début de la ligne |
| 155 | <pre><code class="bash"> |
||
| 156 | tlsmgr unix - - n 1000? 1 tlsmgr |
||
| 157 | </code></pre> |
||
| 158 | |||
| 159 | 35 | Patrice Nadeau | Relire la configuration |
| 160 | <pre><code class="bash"> |
||
| 161 | systemctl reload postfix |
||
| 162 | 31 | Patrice Nadeau | </code></pre> |
| 163 | 30 | Patrice Nadeau | |
| 164 | 43 | Patrice Nadeau | h3. D'un client vers Postfix |
| 165 | 36 | Patrice Nadeau | |
| 166 | 37 | Patrice Nadeau | > Voir #54 |
| 167 | |||
| 168 | 40 | Patrice Nadeau | Si un certificat externe n'est pas disponible, en généré un local : |
| 169 | 38 | Patrice Nadeau | <pre><code class="bash"> |
| 170 | cd /etc/postfix |
||
| 171 | openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509 |
||
| 172 | </code></pre> |
||
| 173 | |||
| 174 | 36 | Patrice Nadeau | Dans le fichier _/etc/postfix/main./cf_ |
| 175 | 32 | Patrice Nadeau | <pre><code class="bash"> |
| 176 | # Utilise l'encryption si disponible |
||
| 177 | 1 | Patrice Nadeau | smtp_tls_security_level = may |
| 178 | # Ajoute les messages TLs au journal |
||
| 179 | smtp_tls_loglevel = 1 |
||
| 180 | 41 | Patrice Nadeau | # Fichiers du certificat |
| 181 | 38 | Patrice Nadeau | smtpd_tls_key_file = /etc/postfix/smtpd.key |
| 182 | smtpd_tls_cert_file = /etc/postfix/smtpd.cert |
||
| 183 | 1 | Patrice Nadeau | </code></pre> |
| 184 | 37 | Patrice Nadeau | |
| 185 | Relire la configuration |
||
| 186 | <pre><code class="bash"> |
||
| 187 | systemctl reload postfix |
||
| 188 | </code></pre> |
||
| 189 | 32 | Patrice Nadeau | |
| 190 | 46 | Patrice Nadeau | Si le serveur est disponible à partir d'internet, on peux faire un test avec https://starttls.info/ |
| 191 | |||
| 192 | 44 | Patrice Nadeau | h2. Domaines supplémentaires |
| 193 | |||
| 194 | > Voir #55 |
||
| 195 | |||
| 196 | 13 | Patrice Nadeau | h2. Dépannage |
| 197 | 8 | Patrice Nadeau | |
| 198 | La commande *mailq* permet de voir les requêtes en attentes. |
||
| 199 | 18 | Patrice Nadeau | |
| 200 | 23 | Patrice Nadeau | h3. Messages ne s'envoient pas |
| 201 | |||
| 202 | 26 | Patrice Nadeau | > Vu sur une nouvelle installation openSUSE 13.2 |
| 203 | |||
| 204 | 27 | Patrice Nadeau | La commande _postqueue -p_ affiche : *address resolver failure* |
| 205 | |||
| 206 | 26 | Patrice Nadeau | Modififer le fichier */etc/postfix/main.cf* |
| 207 | <pre><code class="bash"> |
||
| 208 | disable_dns_lookups = yes |
||
| 209 | </code></pre> |
||
| 210 | 25 | Patrice Nadeau | |
| 211 | 23 | Patrice Nadeau | h3. Messages *error: open database /etc/postfix/relay.db: No such file or directory* |
| 212 | |||
| 213 | > Vu sur une nouvelle installation openSUSE 13.2 |
||
| 214 | |||
| 215 | Exécuter la commande |
||
| 216 | <pre><code class="bash"> |
||
| 217 | postmap /etc/postfix/relay |
||
| 218 | 18 | Patrice Nadeau | </code></pre> |