Bonjour,
je viens chercher de l’aide car je suis désespéré avec mon serveur mail.
Ca fait des jours que j’essaie de le faire fonctionner.
Mon serveur est un Raspberry Pi. Pas une bête de course mais suffisant.
J’ai suivi le tutoriel suivant : http://www.clubic.com/forum/hardware-general/raspberry-pi-ze-topic-id877239-page1.html C’est spécialement le point 4.
C’est ainsi que j’ai paramétré mon pare-feu (IPTables), portsentry et fail2ban.
Ensuite pour postfix, j’ai suivi le tuto suivant : http://www.isalo.org/wiki.debian-fr/Configuration_d%27un_serveur_mail_avec_Postfix#Pr.C3.A9requis
Mon routeur redirige les ports 25, 110 et 143 vers mon serveur. Et j’ai ouvert ces ports sur mon pare-feu.
Au point où j’en suis, je peux recevoir des mails d’un user à l’autre sur mon serveur. Je peux aussi envoyer des mails vers l’extérieur (par exemple vers mon adresse gmail).
Mais je ne peux pas recevoir de mail de l’extérieur.
Je n’arrive pas à comprendre ce qui ne va pas.
Quand j’envoie un mail de GMail, je n’ai aucune trace dans /var/log/mail.log
Comme s’il n’était pas arrivé sur le serveur.
Je suis bien conscient que je ne vous donne pas beaucoup d’infos… Le problème c’est que je ne vois tellement pas ce qui coince que je ne vois pas quoi vous dire… Pour moi tout est en ordre et devrait marcher.
A titre d’information :
Mon fichier de zone chez GANDI :
@ 10800 IN A 95.182.252.118
smtp 300 IN A 95.182.252.118
www 10800 IN A 95.182.252.118
@ 28800 IN MX 10 smtp
Le script que j’ai utilisé pour configurer mon pare-feu :
[code]#!/bin/sh
#Suppression des règles précédentes
iptables -t filter -F
iptables -t filter -X
Définition des blocages pour les entrées et le suivi et autorisation des sorties
iptables -t filter -P INPUT DROP
iptables -t filter -P FORWARD DROP
iptables -t filter -P OUTPUT ACCEPT
Conservations des connexions déjà établies
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
Autorisation du loopback
iptables -t filter -A INPUT -i lo -j ACCEPT
iptables -t filter -A OUTPUT -o lo -j ACCEPT
Autorisation du port HTTP (80)
iptables -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
Autorisation du port SSH (26)
iptables -t filter -A INPUT -p tcp --dport 26 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 26 -j ACCEPT
Autorisation du port SMTP (25)
iptables -t filter -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 25 -j ACCEPT
Autorisation du port POP3 (110)
iptables -t filter -A INPUT -p tcp --dport 110 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 110 -j ACCEPT
Autorisation du port IMAP (143)
iptables -t filter -A INPUT -p tcp --dport 143 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 143 -j ACCEPT
Autorisation du Ping et du Pong ^^
iptables -t filter -A INPUT -p icmp -j ACCEPT
iptables -t filter -A OUTPUT -p icmp -j ACCEPT
Regles pour éviter (en partie) les attaques de type Déni de Service
iptables -A FORWARD -p tcp --syn -m limit --limit 1/second -j ACCEPT
iptables -A FORWARD -p udp -m limit --limit 1/second -j ACCEPT
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/second -j ACCEPT
Limitation (loin d’être totale) du scan de ports
iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT[/code]
Mon fichier mail.cf pour postfix :
[code]# See /usr/share/postfix/main.cf.dist for a commented, more complete version
Debian specific: Specifying a file name will cause the first
line of that file to be used as the name. The Debian default
is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
appending .domain is the MUA’s job.
append_dot_mydomain = no
Uncomment the next line to generate “delayed mail” warnings
#delay_warning_time = 4h
readme_directory = no
TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
Activer l’identification SASL
smtpd_sasl_auth_enable = yes
Utiliser le système d’identification de Dovecot
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_sasl_authenticated_header = yes
See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
information on enabling SSL in the smtp client.
myhostname = smtp.snyers.me
mydomain = snyers.me
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = snyers.me smtp.snyers.me localhost localhost.snyers.me
mynetworks = 127.0.0.0/8,192.168.0.0/28
#mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 51200000
recipient_delimiter = +
inet_interfaces = all
home_mailbox = Maildir/
#mailbox_command =
inet_protocols = ipv4
relayhost = smtp.voo.be
relay_domains = $mydestination[/code]
Le hostname de mon serveur est smtp.snyers.me
Pour le reste, j’utilise fail2ban et portsentry.
Le résultat de iptables -L donne :
[code]Chain INPUT (policy DROP)
target prot opt source destination
fail2ban-dovecot tcp – anywhere anywhere multiport dports smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s
fail2ban-postfix tcp – anywhere anywhere multiport dports smtp,ssmtp
fail2ban-apache tcp – anywhere anywhere multiport dports http,https
fail2ban-ssh tcp – anywhere anywhere multiport dports ssh,26
ACCEPT all – anywhere anywhere state RELATED,ESTABLISHED
ACCEPT all – anywhere anywhere
ACCEPT tcp – anywhere anywhere tcp dpt:http
ACCEPT tcp – anywhere anywhere tcp dpt:26
ACCEPT tcp – anywhere anywhere tcp dpt:smtp
ACCEPT tcp – anywhere anywhere tcp dpt:pop3
ACCEPT tcp – anywhere anywhere tcp dpt:imap2
ACCEPT icmp – anywhere anywhere
ACCEPT tcp – anywhere anywhere tcp dpt:smtp
Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT tcp – anywhere anywhere tcpflags: FIN,SYN,RST,ACK/SYN limit: avg 1/sec burst 5
ACCEPT udp – anywhere anywhere limit: avg 1/sec burst 5
ACCEPT icmp – anywhere anywhere icmp echo-request limit: avg 1/sec burst 5
ACCEPT tcp – anywhere anywhere tcpflags: FIN,SYN,RST,ACK/RST limit: avg 1/sec burst 5
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all – anywhere anywhere state RELATED,ESTABLISHED
ACCEPT all – anywhere anywhere
ACCEPT tcp – anywhere anywhere tcp dpt:http
ACCEPT tcp – anywhere anywhere tcp dpt:26
ACCEPT tcp – anywhere anywhere tcp dpt:smtp
ACCEPT tcp – anywhere anywhere tcp dpt:pop3
ACCEPT tcp – anywhere anywhere tcp dpt:imap2
ACCEPT icmp – anywhere anywhere
Chain fail2ban-apache (1 references)
target prot opt source destination
RETURN all – anywhere anywhere
Chain fail2ban-dovecot (1 references)
target prot opt source destination
RETURN all – anywhere anywhere
Chain fail2ban-postfix (1 references)
target prot opt source destination
RETURN all – anywhere anywhere
Chain fail2ban-ssh (1 references)
target prot opt source destination
RETURN all – anywhere anywhere[/code]
Voilà. Je ne sais pas trop quoi ajouter. Si vous avez besoin d’infos supplémentaires, n’hésitez pas.
Un grand merci pour votre aide. Cela fait des semaines que je cherche et je suis vraiment à court d’idées…
Bonne journée.