Sécurité de postfix

Fermé
8nico7 Messages postés 6 Date d'inscription lundi 7 avril 2008 Statut Membre Dernière intervention 18 avril 2008 - 14 avril 2008 à 11:36
 8nico7 - 18 avril 2008 à 15:16
Bonjour,

Je suis débutant sous linux, je viens d'installer mon serveur de messagerie avec Postfix+MySQL+Courrier-IMAP(POP). Tout a l'air de fonctionner à merveille, j'arrive à émettre en local et vers l'extérieur et pour la réception c'est pareil.
Mon souci c'est la mise en œuvre d'un brin de sécurité.

Quelle solution mettre en place pour :
-Filtrer (ou du moins identifier les spams)
-Empêcher l'utilisation de mon serveur comme relai SMTP par des gens qui ne font pas parti du domaine de mes utilisateur.
Je suis preneur de tutos!

Merci

3 réponses

stopher Messages postés 5 Date d'inscription lundi 14 avril 2008 Statut Membre Dernière intervention 18 avril 2008
14 avril 2008 à 12:16
Salut ,

Par defaut , postfix est paramétré pour éviter de fonctionner en open relay
Grace à mynetworks .
Ensuite pour eliminer du spam , tu peux dans un premier temps utiliser les rbl , et autres régles dans :
smtpd_recipient_restrictions

Puis pour enlever encore 90% de spam , utiliser une greylist ... déprécié par certains .. perso je trouve ca bien ...

Et enfin , tu peux utiliser spamassassin , clamav (pour les virus) , amavisd-new , DCC , razor ...

Pour t'aider à commencer :

http://memo.lindev.fr/index.php?categorie=4

0
Merci beaucoup,

Ces tutos on l'air très clair, je court de suite les exploiter.
0
8nico7 Messages postés 6 Date d'inscription lundi 7 avril 2008 Statut Membre Dernière intervention 18 avril 2008
17 avril 2008 à 14:51
J'ai bien suivi tout cela avec attention. J'ai opté pour la solution Clamav, Spamassassin, amavisd-new. Tout ces paquet sont correctement installés et ont l'air de tourné correctement (ps -aux). J'y ai modifié les paramètre de configuration pour ma configuration perso.
Les arrive lorsque j'édite la ligne "content_filter=smtp-amavis:[127.0.0.1]:10024" dans mon main.cf.

J'obtiens alors dans mes logs:
postfix/qmgr[18231]: warning: connect to transport smtp-amavis: Connection refused

puis:
postfix/error[18284]: B115C6BCDD: to=<***@neuf.fr>, relay=none, delay=5253, delays=5253/0.04/0/0.03, dsn=4.3.0, status=deferred (mail transport unavailable)

Je pense que le couplage amavis/postfix est en cause.

Je suis près a présenter le détail de ma conf si ce sujet intéresse quelqu'un même si cela risque d'être long.
Je débute sous Linux et j'apprends juste a monter ce serveur pour mon stage en entreprise.

Merci
0
stopher Messages postés 5 Date d'inscription lundi 14 avril 2008 Statut Membre Dernière intervention 18 avril 2008 > 8nico7 Messages postés 6 Date d'inscription lundi 7 avril 2008 Statut Membre Dernière intervention 18 avril 2008
17 avril 2008 à 15:28
Postes nous ta conf :

postconf -n

Et ton master.cf

As tu bien entré la commande :

postmap transport

Apres avoir edité/modifié ce fichier ?
0
8nico7 Messages postés 6 Date d'inscription lundi 7 avril 2008 Statut Membre Dernière intervention 18 avril 2008
17 avril 2008 à 15:39
postconf -n :

alias_database = hash:/usr/local/etc/postfix/aliases
alias_maps = hash:/etc/aliases
config_directory = /etc/postfix
html_directory = no
inet_interfaces = all
mail_owner = postfix
mailbox_size_limit = 0
mailq_path = /usr/local/bin/mailq
mydestination = servmail, localhost.localdomain, localhost
mydomain = $myhostname
myhostname = ***.dyndns.org
mynetworks = 127.0.0.0/8 10.0.0.0/24 10.0.4.0/24 ***.252.**.59/32 ***.252.***.101/32 ***.167.**.143/32
mynetworks_style = host
myorigin = $myhostname
newaliases_path = /usr/local/bin/newaliases
readme_directory = no
recipient_delimiter = +
relay_domains = $mydestination
relayhost = smtp.orange.fr
sendmail_path = /usr/local/sbin/sendmail
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache
smtpd_sender_login_maps = mysql:/usr/local/etc/postfix/mysql_virtual_sender.cf
smtpd_tls_cert_file = /etc/postfix/smtpd.cert
smtpd_tls_key_file = /etc/postfix/smtpd.key
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtpd_use_tls = yes
unknown_local_recipient_reject_code = 550
virtual_alias_maps = mysql:/usr/local/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:120
virtual_mailbox_base = /usr/local/virtual
virtual_mailbox_domains = mysql:/usr/local/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = 51200000
virtual_mailbox_maps = mysql:/usr/local/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 100
virtual_transport = virtual
virtual_uid_maps = static:109


Pour le master.cf:

smtp inet n - - - - smtpd
#submission inet n - - - - smtpd
# -o smtpd_enforce_tls=yes
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#smtps inet n - - - - smtpd
# -o smtpd_tls_wrappermode=yes
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#628 inet n - - - - qmqpd
pickup fifo n - - 60 1 pickup
cleanup unix n - - - 0 cleanup
qmgr fifo n - n 300 1 qmgr
#qmgr fifo n - - 300 1 oqmgr
tlsmgr unix - - - 1000? 1 tlsmgr
rewrite unix - - - - - trivial-rewrite
bounce unix - - - - 0 bounce
defer unix - - - - 0 bounce
trace unix - - - - 0 bounce
verify unix - - - - 1 verify
flush unix n - - 1000? 0 flush
proxymap unix - - n - - proxymap
smtp unix - - - - - smtp
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay unix - - - - - smtp
-o smtp_fallback_relay=
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - - - - showq
error unix - - - - - error
retry unix - - - - - error
discard unix - - - - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - - - - lmtp
anvil unix - - - - 1 anvil
scache unix - - - - 1 scache
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent. See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop unix - n n - - pipe
flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# See the Postfix UUCP_README file for configuration details.
#
uucp unix - n n - - pipe
flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail unix - n n - - pipe
flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp unix - n n - - pipe
flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix - n n - 2 pipe
flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman unix - n n - - pipe
flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
${nexthop} ${user}


Et pour la commande postmap transport

postfix/postmap[18580]: fatal: open transport: No such file or directory
0
8nico7 Messages postés 6 Date d'inscription lundi 7 avril 2008 Statut Membre Dernière intervention 18 avril 2008
18 avril 2008 à 08:58
Finalement ça n'intéresse plus personne ?
:(
0
stopher Messages postés 5 Date d'inscription lundi 14 avril 2008 Statut Membre Dernière intervention 18 avril 2008
18 avril 2008 à 11:53
Oups ,
J'ai oublié d'ajouter la modification à apporter au fichier master.cf :

j'ai mis à jour :

http://memo.lindev.fr/index.php/2008/04/18/2-passerelle-anti-spam-sous-debian

A la fin de l'article ...
0
8nico7 Messages postés 6 Date d'inscription lundi 7 avril 2008 Statut Membre Dernière intervention 18 avril 2008 > stopher Messages postés 5 Date d'inscription lundi 14 avril 2008 Statut Membre Dernière intervention 18 avril 2008
18 avril 2008 à 12:02
???
je comprend pas
0
stopher Messages postés 5 Date d'inscription lundi 14 avril 2008 Statut Membre Dernière intervention 18 avril 2008 > 8nico7 Messages postés 6 Date d'inscription lundi 7 avril 2008 Statut Membre Dernière intervention 18 avril 2008
18 avril 2008 à 12:08
Et bien commen indiqué sur le tuto ,
Tu édites ton fichier master.cf :

/etc/postfix/master.cf , et tu ajoutes à la fin de celui-ci les lignes que j'ai ajouté : a savoir :

smtp-amavis unix - - y - 2 smtp
-o smtp_data_done_timeout=1200
-o smtp_send_xforward_command=yes
-o disable_dns_lookups=yes
-o max_use=20
127.0.0.1:10025 inet n - y - - smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o smtpd_data_restrictions=reject_unauth_pipelining
-o smtpd_end_of_data_restrictions=
-o mynetworks=127.0.0.0/8
-o strict_rfc821_envelopes=yes
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000
-o smtpd_client_connection_count_limit=0
-o smtpd_client_connection_rate_limit=0
-o receive_override_options=no_address_mappings,no_header_body_checks,no_unknown_recipient_checks
0
8nico7 > stopher Messages postés 5 Date d'inscription lundi 14 avril 2008 Statut Membre Dernière intervention 18 avril 2008
18 avril 2008 à 15:16
j'insiste vraiment pour passer par amavis, j'ai donc rajouter ces quelques lignes :

Dans le main.cf:
content_filter = vscan:

Et dans le master.cf:
vscan unix - n n - 10 pipe user=amavis argv=/usr/sbin/amavis ${sender} ${recipient}
localhost:10025 inet n - n - - smtpd -o content_filter=

J'ai relancer Postfix et maintenant il à l'air de démarrer correctement Amavis:

postfix/pickup[23165]: A8F176BD37: uid=1000 from=<nicolas>

Apr 18 14:54:02 servmail postfix/cleanup[23175]: A8F176BD37: message-id=<20080418125402.A8F176BD37@***.dyndns.org>

Apr 18 14:54:02 servmail postfix/qmgr[23166]: A8F176BD37: from=<nicolas@***.dyndns.org>, size=325, nrcpt=1 (queue active)

Apr 18 14:54:07 servmail amavisd[23178]: starting. amavis 0.3.12 Fri Apr 18 14:09:41 CEST 2008


Le problème arrive après maintenant c'est le scan des mail par clamv qui foire tout:

Apr 18 14:54:07 servmail amavisd[23178]: Virus scanner failure: /usr/local/bin/clamscan (error code: 40)
Apr 18 14:54:07 servmail amavisd[23178]: Virus scanner failure: Clamd - can't connect to daemon
Apr 18 14:54:07 servmail amavisd[23178]: All virus scanners failed - mail requeued (message-id=<20080418125402.A8F176BD37@aviva2.dyndns.org>)
Apr 18 14:54:07 servmail amavisd[23178]: do_exit:542 - ending execution with 75
Apr 18 14:54:07 servmail postfix/pipe[23177]: A8F176BD37: to=<nico@***.dyndns.org>, relay=vscan, delay=5.3, delays=0.23/0.06/0/5, dsn=4.3.0, status=deferred (temporary failure. Command output: ERROR: register_option: No long option for -w ERROR: Can't parse the command line )

Pourtant lorsque je fais un ps aux, le démon clamd et freshsclam tourne. Je ne comprend pas cette erreur et au final les mail reste en queue.
0