Data Query Service (DQS)

16 settembre 2026 by Roberto Puzzanghera 0 commenti

Abbiamo già creato un account presso la Blocklist via DNS Query in precedenza, nella pagina dedicata a RBL (si veda qui).

Installazione del plugin per SpamaAssassin

Intanto disabilitiamo le query ordinarie aggiungendo questo in /etc/mail/spamassassin/local.cf:

# disable spamhaus 
score URIBL_DBL_SPAM 0 
score URIBL_DBL_PHISH 0 
score URIBL_DBL_MALWARE 0 
score URIBL_DBL_ABUSE 0 
score URIBL_DBL_ABUSE_REDIR 0 
score URIBL_DBL_ABUSE_PHISH 0 
score URIBL_DBL_ABUSE_MALWARE 0 
score URIBL_DBL_BLOCKED 0 
score URIBL_DBL_BLOCKED_OPENDNS 0
# disable DNSWL 
score RCVD_IN_DNSWL_BLOCKED 0 
score RCVD_IN_DNSWL_MED 0 
score RCVD_IN_DNSWL_HI 0 
score RCVD_IN_DNSWL_LOW 0

Scaricare l'ultimo pacchetto:

git clone https://github.com/spamhaus/spamassassin-dqs

Le cose ora vanno in modo leggermente diverso a seconda che il servizio HBL sia abilitato o meno (lo è solo per gli account a pagamento).

Entrare nella cartella 4.0.0+ e lanciare il test per confermare che la nostra chiave sia valida anche per HBL (il chè non significa che sia pure abilitata):

sh hbltest.sh
	Please input your DQS key: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
	Looking up test record for HBL... done
	Your DQS key xxxxxxxxxxxxxxxxxxxxxxxxxxxx is enabled for HBL
	You can copy sh_hbl.cf and sh_hbl_scores.cf if you want HBL enabled

Ora è necessario modificare alcuni dei file di configurazione con il contenuto esatto della chiave (sostituire xxxxxxxxxxxxxxxxxxxxxxxxx con il contenuto della chiave):

sed -i -e 's/your_DQS_key/xxxxxxxxxxxxxxxxxxxxxxxxxxx/g' sh.cf
sed -i -e 's/your_DQS_key/xxxxxxxxxxxxxxxxxxxxxxxxxxx/g' sh_hbl.cf

Se si sta usando FreeBSD, i comandi cambiano leggermente:

sed -i "" -e 's/your_DQS_key/xxxxxxxxxxxxxxxxxxxxxxxx/g' sh.cf
sed -i "" -e 's/your_DQS_key/xxxxxxxxxxxxxxxxxxxxxxxx/g' sh_hbl.cf

Se non si ha HBL abilitato, è sufficiente copiare i due file seguenti nella cartella di configurazione:

cp sh.cf sh_scores.cf /etc/mail/spamassassin

Ora si proceda più sotto nella sezione test.

Se invece si ha HBL abilitato, modificare il file sh.pre nella prima riga:

loadplugin       Mail::SpamAssassin::Plugin::SH <config_directory>/SH.pm

E' necessario sostituire <config_directory> con la propria cartella di configurazione, che è /etc/mail/spamassassin. Quindi la riga diventa:

loadplugin       Mail::SpamAssassin::Plugin::SH /etc/mail/spamassassin/SH.pm

Se si ha una chiave con HBL abilitato, e assumendo che la cartella di configurazione sia /etc/mail/spamassassin, copiare lì i file di configurazione:

cp SH.pm sh.cf sh_scores.cf sh_hbl.cf sh_hbl_scores.cf sh.pre /etc/mail/spamassassin

Ora abilitare HBL modificando il file /etc/mail/spamassassin/v342.pre. E' necessario localizzare la riga:

loadplugin Mail::SpamAssassin::Plugin::HashBL

ed eventualmente rimuovere il cancelletto # iniziale.

Riavviare SpamAssassin:

spamdctl restart

Testare il setup in questo modo:

spamassassin --lint

se non si ottiene nulla come output allora il test è andato bene.

Testare il filtro

Andare alla pagina https://blt.spamhaus.com/ e inserire un indirizzo email valido. Quindi aggiungere la chiave DQS e lanciare i test:

Si otterrà un risultato del genere:

Qui HBL è disabilitato, mentre i messaggi con i test DBL e ZRD hanno apparentemente fallito. Assicurarsi che invece i messaggi con il test DBL e ZRD siano stati bloccati da SpamAssassin controllando la cartella spam::

Content analysis details:   (19.5 points, 5.0 required)

 pts rule name              description
---- ---------------------- --------------------------------------------------
 0.7 SPF_HELO_SOFTFAIL      SPF: HELO does not match SPF record (softfail)
-0.0 BAYES_20               BODY: Bayes spam probability is 5 to 20%
                            [score: 0.0573]
 0.0 DMARC_MISSING          Missing DMARC policy
 2.8 TXREP                  TXREP: Score normalizing based on sender's reputation
 8.0 SH_DBL_HEADERS         A domain found in headers (mail from, reply-to etc..)
                            is listed in DBL
                            [dbl-dqs.blt.spamhaus.net]
 8.0 SH_DBL_BODY            The domain of an email address found in body is listed in
                             DBL
                            [dbl-dqs.blt.spamhaus.net]
Content analysis details:   (12.1 points, 5.0 required)

 pts rule name              description
---- ---------------------- --------------------------------------------------
-0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 8.0 SH_HELO_ZRD_VERY_FRESH The domain used in the HELO string is listed
                            in ZRD and the domain age is between 0 and 4
                            hours
                            [zrd-dqs.blt.spamhaus.net]
-0.0 BAYES_20               BODY: Bayes spam probability is 5 to 20%
                            [score: 0.1579]
 1.0 FORGED_SPF_HELO        No description available.
 0.4 KHOP_HELO_FCRDNS       Relay HELO differs from its IP's reverse DNS
 0.0 DMARC_MISSING          Missing DMARC policy
 2.7 TXREP                  TXREP: Score normalizing based on sender's reputation

Aggiungi un commento

qmail notes

Pay me a coffee:

PayPal - The safer, easier way to pay online.

LXC scripts
Other contents
Guide per gli utenti
Ultimi commenti
Articoli recenti

RSS feeds