Debian 9 Stretch - Serveur LAMP - Serveur MAIL Postfix & cie - TIPS
Postfix et compagnie MAIL05 Amavis, Spams et Viruspar skay Dernière mise à jour Dimanche 17 Février 2019 • 902 consultations
# apt-get install clamav-daemon clamav-freshclam spamassassin amavisd-new arj nomarch lzop cabextract razor pyzor p7zip-full pax zip unzip unrar-free mailutils Préparation de Amavis, Spamassassin et ClamavLe principe de Amavis est de monitorer ces divers outils. Il récupère de postfix les messages, les traite avec clamav (antivirus) et spamassin et repasse dans postfix selon leur état. Autorisations entre clamav et amavis, dossier de quarantaine pour les virus et dossier de traitement temporaire de tests... # usermod -a -G clamav amavis # mkdir -p /var/spool/virusmails # chown amavis:amavis /var/spool/virusmails # chmod 0770 /var/spool/virusmails # usermod -a -G amavis clamav # chmod g+rx /var/lib/amavis/tmp # chmod 0770 /var/lib/amavis/tmp
Mettre à jour les divers outils installés, d'abord Clamav, patience ! # freshclam Puis Spamassassin # sa-update Pour activer le démon spamd, éditer /etc/default/spamassassin, chercher et passer la variable ENABLED à 1 # nano /etc/default/spamassassin# Change to "1" to enable spamd on systems using sysvinit: ENABLED=1 Configuration de AmavisLe dossier de configuration de Amavis se situe dans /etc/amavis/conf.d et fonctionne un peu de la même manière que les fichiers de configuration de dovecot. # cd /etc/amavis/conf.d On fait une copie du fichier et on l'édite # cp 01-debian 01-debian.save # nano 01-debian$ENV{PATH} = $path = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/usr/bin:/bin'; $file = 'file'; $gzip = 'gzip'; $bzip2 = 'bzip2'; $lzop = 'lzop'; $rpm2cpio = ['rpm2cpio.pl','rpm2cpio']; $cabextract = 'cabextract'; $uncompress = ['uncompress', 'gzip -d', 'zcat']; $unfreeze = ['unfreeze', 'freeze -d', 'melt', 'fcat']; #disabled (non-free, no security support) $arc = ['nomarch', 'arc']; $unarj = ['arj', 'unarj']; $unrar = ['unrar-free']; # $zoo = 'zoo'; $lha = 'lha'; $lha = undef; $pax = 'pax'; $cpio = 'cpio'; $ar = 'ar'; $ripole = 'ripole'; $dspam = 'dspam'; 1; # ensure a defined return # cp 05-domain_id 05-domain_id.save # nano 05-domain_iduse strict; chomp($mydomain = `head -n 1 /etc/mailname`); @local_domains_acl = ( "." ); # Permet de scanner tous les domaines # cp 15-content_filter_mode 15-content_filter_mode.save # nano 15-content_filter_mode####### Décommenter les lignes suivantes @bypass_virus_checks_maps = ( %bypass_virus_checks, @bypass_virus_checks_acl, $bypass_virus_checks_re); @bypass_spam_checks_maps = ( %bypass_spam_checks, @bypass_spam_checks_acl, $bypass_spam_checks_re); # cp 20-debian_defaults 20-debian_defaults.save # nano 20-debian_defaults# Extrait des lignes importantes $QUARANTINEDIR = "/var/spool/virusmails"; $quarantine_subdir_levels = 1; # enable quarantine dir hashing $log_recip_templ = undef; # disable by-recipient level-0 log entries $DO_SYSLOG = 1; # log via syslogd (preferred) $syslog_ident = 'amavis'; # syslog ident tag, prepended to all messages $syslog_facility = 'mail'; $syslog_priority = 'debug'; # switch to info to drop debug output, etc $enable_db = 1; # enable use of BerkeleyDB/libdb (SNMP and nanny) $enable_global_cache = 1; # enable use of libdb-based cache if $enable_db=1 $inet_socket_port = 10024; # default listening socket $sa_spam_subject_tag = '*****SPAM***** '; $sa_tag_level_deflt = undef; # add spam info headers if at, or above that level $sa_tag2_level_deflt = 6.00; # add 'spam detected' headers at that level $sa_kill_level_deflt = 6.00; # triggers spam evasive actions $sa_dsn_cutoff_level = 25; # spam level beyond which a DSN is not sent $sa_mail_body_size_limit = 200*1024; # don't waste time on SA if mail is larger $sa_local_tests_only = 0; # only tests which do not require internet access? $MAXLEVELS = 14; $MAXFILES = 1500; $MIN_EXPANSION_QUOTA = 100*1024; # bytes $MAX_EXPANSION_QUOTA = 300*1024*1024; # bytes $final_virus_destiny = D_DISCARD; # (data not lost, see virus quarantine) $final_banned_destiny = D_BOUNCE; # D_REJECT when front-end MTA $final_spam_destiny = D_PASS; $final_bad_header_destiny = D_PASS; # False-positive prone (for spam) $enable_dkim_verification = 0; #disabled to prevent warning $virus_admin = "root@$mydomain"; # due to D_DISCARD default $X_HEADER_LINE = "Debian $myproduct_name at $mydomain"; # cp 50-user 50-user.save # nano 50-useruse strict; $spam_quarantine_to = undef; # Do nothing with Spam $spam_admin = "root"; # Where to send Notification 1; # ensure a defined return |
![]() |