Author: Tafaz
Visits: 1827
Date: 09.04.2010
e scorriamo fino alla fine dell'ACL e appena prima dell'inizio della successiva che solitamente è
# ACL that is used after the DATA command
check_message:
inseriamo
# GreyListing
defer message = Sender verification for $sender_host_address in progress. Please try later.
log_message = greylisted.
!senders = :
!hosts = : +relay_hosts : +whitelist_hosts : +whitelist_hosts_ip
!authenticated = *
!domains = : ${if exists {/etc/greylistd/skip-greylist}\
{/etc/greylistd/skip-greylist}{}}
domains = +local_domains : +relay_domains
verify = recipient/callout=20s,use_sender,defer_ok
condition = ${readsocket{/var/run/greylistd/socket}\
{--grey \
$sender_host_address \
$sender_address \
@$domain}\
{5s}{}{false}}
deny message = $sender_host_address is blacklisted
log_message = blacklisted.
!senders = :
!authenticated = *
verify = recipient/callout=20s,use_sender,defer_ok
condition = ${readsocket{/var/run/greylistd/socket}\
{--black \
$sender_host_address \
$sender_address \
$local_part@$domain}\
{5s}{}{false}}
ora appena sotto al codice che abbiamo incollato troviamo la seguente ACL
# ACL that is used after the DATA command
check_message:
e appena prima del comando accept inseriamo
defer
message = Sender verification for $sender_host_address in progress. Please try later.
log_message = greylisted.
senders = :
!hosts = : +relay_hosts : +whitelist_hosts : +whitelist_hosts_ip
!authenticated = *
condition = ${readsocket{/var/run/greylistd/socket}\
{--grey \
$sender_host_address \
$recipients}\
{5s}{}{false}}
deny
message = $sender_host_address is blacklisted from delivering \
mail from <$sender_address> to <$recipients>.
log_message = blacklisted.
!senders = :
!authenticated = *
condition = ${readsocket{/var/run/greylistd/socket}\
{--black \
$sender_host_address \
$recipients}\
{5s}{}{false}}
a questo punto possiamo salvare exim.conf e riavviare exim con
/etc/init.d/exim restart
se non si sono verificati problemi durante il riavvio di exim possiamo andare a controllare i log di exim con
tailf -f /var/log/exim/mainlog
e troveremo le azioni di greylist e delle RBL nei seguenti formati
2008-03-17 13:05:17 H=hore.iptelecom.net.ua [212.xx.224.8] F=<ins> temporarily rejected RCPT : greylisted.
2010-04-13 09:50:11 H=([41.130.13.69]) [41.130.13.69] F=<xxxx@yyyyyyy.com> rejected RCPT <xxxx@yyyyyyy.com>: Email blocked by SPAMHAUS - to unblock see http://www.example.com/
e per avere le statistiche di greylist possiamo usare
srv01:~# greylist stats
Statistics since Fri Apr 2 12:48:23 2010 (10 days and 21 hours ago)
--------------------------------------------------------------------
2798 items, matching 3374 requests, are currently whitelisted
0 items, matching 0 requests, are currently blacklisted
139 items, matching 144 requests, are currently greylisted
Of 3945 items that were initially greylisted:
- 2798 ( 70.9%) became whitelisted
- 1147 ( 29.1%) expired from the greylist
per aggiungere ip di domini fidati in whitelist basta inserirli nel file /etc/greylistd/skip-greylist un ip per riga.
per aggiungere alla whitelist gli ip di molti ISP noti (come gmail e yahoo) è possibile ottenere una lista aggiornata al seguente indirizzo http://users.aber.ac.uk/auj/spam/iplist.txt. Ho creato un semplice script in PHP da eseguire in cron in modo da aggiornare giornalmente l'elenco di domini in whitelist con quelli contenuti nella lista al link indicato
<?php
$f = file_get_contents("http://users.aber.ac.uk/auj/spam/iplist.txt");
if(preg_match_all("#([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})#si",$f,$r)){ // legge gli ip dal file
foreach($r[0] as $ip){
$r = exec("/usr/bin/greylist check ".escapeshellarg($ip)); // controlla se l'ip è già in whitelist
if($r!='white'){
exec("/usr/bin/greylist add --white ".escapeshellarg($ip)); // e lo inserisce in whitelist
}
}
} else {
echo "GREYLIST: nothing to import";
}
?>
Se vuoi discutere con noi su questo articolo o comunque vuoi porci delle domande usa il nostro Forum

