########################################
#### 1. Paquetes necesarios
########################################
1.1 Instalar repositorio EPEL
mkdir /root/tmp
cd /root/tmp
wget -c http://mirror.uv.es/mirror/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
1.2 Deshabilitar repositorio EPEL
yum install yum-utils
yum-config-manager --disable epel
1.3 Instalar los paquetes necesarios (muchas dependencias)
yum --enablerepo epel install amavisd-new
yum --enablerepo epel install clamav
yum install perl-YAML.noarch
1.4 Copias de seguridad
cp -p /etc/postfix/main.cf /etc/postfix/main.cf.amavis
cp -p /etc/postfix/master.cf /etc/postfix/master.cf.amavis
cp -p /etc/amavisd/amavisd.conf /etc/amavisd/amavisd.conf.amavis
1.5 Dependencias de perl
yum install perl-CPAN
cpan
install CPAN
reload cpan
install Mail::SPF
########################################
#### 2. Configuración ClamAV
########################################
2.1 Comentar línea en /etc/clamd.conf
vim /etc/clamd.conf
#User clam
2.2 Iniciar ClamD
/etc/init.d/clamd start
2.3 Actualizar ClamAv
/usr/bin/freshclam
2.4 Comprobar logs
clear; cat /var/log/clamav/clamd.log
clear; cat /var/log/clamav/freshclam.log
2.5 Arranque automático
chkconfig clamd on
########################################
#### 3. Configuración Amavis
########################################
3.1 Editar amavisd.conf
vim /etc/amavisd/amavisd.conf
$mydomain = 'soluciones.si'; # a convenient default for other settings
$virus_admin = "proveedores\@soluciones.si"; # notifications recip.
$final_bad_header_destiny = D_PASS; # bad header PASS
3.2 Ajustar la ruta de clamd.sock
Antes:
\&ask_daemon, ["CONTSCAN {}\n", "/var/spool/amavisd/clamd.sock"],
Después:
\&ask_daemon, ["CONTSCAN {}\n", "/var/run/clamav/clamd.sock"],
3.3 Iniciar Amavis
/etc/init.d/amavisd start
3.4 Comprobar arranque de Amavis
grep amavis /var/log/maillog
3.5 Arranque automático
chkconfig amavisd on
########################################
#### 4. Configuración Postfix Master
########################################
4.1 Comentar smtpd_milters en /etc/postfix/main.cf
#smtpd_milters = , inet:127.0.0.1:12768
4.2 Añadir a /etc/postfix/master.cf
# Amavis filter
amavisd unix - - - - 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 - - - - smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_delay_reject=no
-o smtpd_client_restrictions=permit_mynetworks,reject
-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 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_header_body_checks,no_unknown_recipient_checks
4.3 Reiniciar postfix
/etc/init.d/postfix restart
4.4 Comprobar funcionamiento postfix
tail -f /var/log/maillog | grep -v pop3d | grep -v imapd | grep -v saslauthd
4.5 Comprobar puertos SMTP (10025)
netstat -natp |grep -i listen | grep master
4.6 Inyectar email en el puerto 10025
telnet 127.0.0.1 10025
mail from:<pruebas@soporte.si>
rcpt to:<pruebas@soporte.si>
data
.
quit
########################################
#### 5. Pruebas
########################################
# Arrancamos amavis en modo debug
/etc/init.d/amavisd stop
/usr/sbin/amavisd -c /etc/amavisd/amavisd.conf debug
cd /root/tmp
wget -c http://www.jetmore.org/john/code/swaks/files/swaks-20130209.0/swaks
chmod +x swaks
export email_pruebas=pruebas@soporte.si
# Envio correo a través de postfix 25
./swaks --to $email_pruebas --header "Subject: Prueba puerto 25" --server 127.0.0.1:25
# Envio correo a través de postfix 10025
./swaks --to $email_pruebas --header "Subject: Prueba puerto 10025" --server 127.0.0.1:10025
# Envio correo a través de Amavis 10024
./swaks --to $email_pruebas --header "Subject: Prueba puerto 10024" --server 127.0.0.1:10024
# Envio correo con virus a través de Amavis 10024
cd /root/tmp
wget -c http://www.eicar.org/download/eicar.com
wget -c http://www.eicar.org/download/eicar_com.zip
./swaks --to $email_pruebas --header "Subject: Prueba EICAR 10024" --server 127.0.0.1:10024 --attach eicar.com
./swaks --to $email_pruebas --header "Subject: Prueba EICAR 10024" --server 127.0.0.1:10024 --attach eicar_com.zip
# Envio correo con spam a través de Amavis 10024
cd /root/tmp
wget -c https://spamassassin.apache.org/gtube/gtube.txt
./swaks --to $email_pruebas --header "Subject: Prueba GTUBE 10024" --server 127.0.0.1:10024 --body gtube.txt
########################################
#### 5. Configuración Postfix Main
########################################
5.1 En el /etc/postfix/main.cf añadir las líneas
# Amavis integration
content_filter=amavisd:[127.0.0.1]:10024
receive_override_options=no_address_mappings
5.2 Reiniciar amavisd (parar el debug y arrancar el daemon)
killall amavisd
/etc/init.d/amavisd start
5.3 Reiniciar postfix
/etc/init.d/postfix restart
tail -f /var/log/maillog | grep -v pop3d | grep -v imapd | grep -v saslauthd