Greylisting con postfix come tecnica antispam: Difference between revisions
Script aggiunta mx |
m Non va con bind9-host. c'è il . alla fine del dominio. |
||
| Line 79: | Line 79: | ||
<pre> | <pre> | ||
for NAME in $(host -t mx | cat > /tmp/addmx <<'EOFile' | ||
#!/bin/bash | |||
cut -c 24- | echo "# Whitelist Greylisted MX" >> /etc/postgrey/whitelist_clients | ||
if [ ! -e /usr/bin/host ]; then | |||
echo host not installed. | |||
if ! apt-get install bind9-host; then | |||
failed to install bind9-host | |||
exit 1 | |||
fi | |||
fi | |||
if [ "$(host --version 2>/dev/null)" == "host version 991529" ]; then | |||
echo using host | |||
for NAME in $(host -t mx rvmgroup.it | cut -c 25- | sort -n | cut -c 4-) | |||
do | |||
host $NAME | cut -c 24- >> /etc/postgrey/whitelist_clients | |||
done | |||
else | |||
echo using bind9-host. You are on your own.... | |||
#for NAME in $(host -t mx rvmgroup.it | cut --delim=" " -f 6- | sort -n | cut --delim=" " -f 2) | |||
# do | |||
# host $NAME | cut --delim=" " -f 7 >> /etc/postgrey/whitelist_clients | |||
# done | |||
fi | |||
EOFile | |||
chmod 755 /tmp/addmx | |||
/tmp/addmx | |||
rm /tmp/addmx | |||
</pre> | </pre> | ||
Revision as of 15:36, 28 July 2006
Il Greylisting dice ad un mail server di rimandare la mail dopo un tot di tempo.
Se la mail è mandata da un vero mailserver, allora la rimanderà, se invece è mandata da uno spammer, difficilmente la rimanderà.
Installazione
Installare postgrey:
sudo apt-get install postgrey
Configurazione di Postfix
Aggiungere questa limitazione alle altre:
check_policy_service inet:127.0.0.1:60000
vi /etc/postfix/main.cf
...
smtpd_recipient_restrictions = permit_mynetworks
permit_sasl_authenticated
reject_unauth_destination
check_sender_access hash:/etc/postfix/whitelist
reject_rbl_client relays.ordb.org
reject_rbl_client nsbl.njabl.org
reject_rbl_client sbl.spamhaus.org
reject_rbl_client cbl.abuseat.org
check_policy_service inet:127.0.0.1:60000
Se non esiste già una whitelist di postfix, crearne una vuota:
sudo touch /etc/postfix/whitelist; sudo postmap /etc/postfix/whitelist
Riavviare Postgrey
/etc/init.d/postgrey restart
Verificare che sia attivo:
pstree -p | grep postgr
??postgrey(18956)
Riavviare postfix:
sudo /etc/init.d/postfix restart
Verifica Funzionamento
Guardare i Log:
sudo tail -f /var/log/mail.log ... Jul 24 15:23:33 ergo postgrey[18546]: Process Backgrounded Jul 24 15:23:33 ergo postgrey[18546]: 2006/07/24-15:23:33 postgrey (type Net::Server::Multiplex) starting! pid(18546) Jul 24 15:23:33 ergo postgrey[18546]: Binding to TCP port 60000 on host 127.0.0.1 Jul 24 15:23:33 ergo postgrey[18546]: Setting gid to "65534 65534" Jul 24 15:23:33 ergo postgrey[18546]: Setting uid to "104" ... Jul 24 15:28:22 ergo postfix/smtpd[18945]: NOQUEUE: reject: RCPT from host65-14.pool8253.interbusiness.it[82.53.14.65]: 450 <carlos.casuscelli@marzottospa.com>: Recipient address rejected: Greylisted for 300 seconds (see http://isg.ee.ethz.ch/tools/postgrey/help/marzottospa.com.html); from=<demay@accordfinancialus.com> to=<carlos.casuscelli@marzottospa.com> proto=SMTP helo=<accordfinancialus.com> Jul 24 15:28:22 ergo postfix/smtpd[18945]: lost connection after RCPT from host65-14.pool8253.interbusiness.it[82.53.14.65] ...
Reportistica
Per ottenere un report dei messaggi bloccati (farlo dopo un giorno) :
sudo cat /var/log/mail.log | sudo postgreyreport | less
Gestione Eccezioni
Caso di backup MX protetti da greylist
Se i backup MX sono già protetti da Greylisting, ci si può fidare delle mail provenienti da loro, e si può inserire il loro indirizzo ip (si può inserire il nome se il loro PTR è quello corrispondente al nome dell'mx) in /etc/postgrey/whitelist_clients, e riavviare postgrey.
Questo comando lo fa (sostituire il nome del dominio):
cat > /tmp/addmx <<'EOFile' #!/bin/bash echo "# Whitelist Greylisted MX" >> /etc/postgrey/whitelist_clients if [ ! -e /usr/bin/host ]; then echo host not installed. if ! apt-get install bind9-host; then failed to install bind9-host exit 1 fi fi if [ "$(host --version 2>/dev/null)" == "host version 991529" ]; then echo using host for NAME in $(host -t mx rvmgroup.it | cut -c 25- | sort -n | cut -c 4-) do host $NAME | cut -c 24- >> /etc/postgrey/whitelist_clients done else echo using bind9-host. You are on your own.... #for NAME in $(host -t mx rvmgroup.it | cut --delim=" " -f 6- | sort -n | cut --delim=" " -f 2) # do # host $NAME | cut --delim=" " -f 7 >> /etc/postgrey/whitelist_clients # done fi EOFile chmod 755 /tmp/addmx /tmp/addmx rm /tmp/addmx