Razor and Pyzor
How to install Razor and Pyzor on CentOS6 (For Anti-spam & SpamAssasin)
razor2+pyzor
---
install Razor and Pyzor on CentOS6 (For Anti-spam & SpamAssasin
Create /etc/yum.repos.d/epel.repo
[epel]
name=EPEL repository
baseurl=http://mirrors.kernel.org/fedora-epel/6/x86_64
enabled=1
gpgcheck=0
Download
Download rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm for CentOS 6
from the Repoforge (RPMforge) repository.
Install Howto
Download the latest rpmforge-release rpm from
http://ftp.tu-chemnitz.de/pub/linux/dag/redhat/el6/en/x86_64/rpmforge/RPMS/
Install rpmforge-release rpm:
# rpm -Uvh rpmforge-release*rpm
Install rpmforge-release rpm package:
# yum install rpmforge-release
[root@mail] yum install pyzor perl-Razor-Agent
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
epel | 4.3 kB 00:00
epel/primary_db | 5.9 MB 00:29
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.
–> Running transaction check
—> Package perl-Razor-Agent.x86_64 0:2.85-6.el6 will be installed
–> Processing Dependency: perl(URI::Escape) for package: perl-Razor-Agent-2.85-6.el6.x86_64
–> Processing Dependency: perl(Net::DNS) for package: perl-Razor-Agent-2.85-6.el6.x86_64
—> Package pyzor.noarch 0:0.5.0-3.el6 will be installed
–> Running transaction check
—> Package perl-Net-DNS.x86_64 0:0.65-5.el6 will be installed
–> Processing Dependency: perl(Digest::HMAC_MD5) for package: perl-Net-DNS-0.65-5.el6.x86_64
—> Package perl-URI.noarch 0:1.40-2.el6 will be installed
–> Running transaction check
—> Package perl-Digest-HMAC.noarch 0:1.01-22.el6 will be installed
–> Processing Dependency: perl(Digest::SHA1) for package: perl-Digest-HMAC-1.01-22.el6.noarch
–> Running transaction check
—> Package perl-Digest-SHA1.x86_64 0:2.12-2.el6 will be installed
–> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
perl-Razor-Agent x86_64 2.85-6.el6 epel 119 k
pyzor noarch 0.5.0-3.el6 epel 57 k
Installing for dependencies:
perl-Digest-HMAC noarch 1.01-22.el6 base 22 k
perl-Digest-SHA1 x86_64 2.12-2.el6 base 49 k
perl-Net-DNS x86_64 0.65-5.el6 base 232 k
perl-URI noarch 1.40-2.el6 base 117 k
Transaction Summary
================================================================================
Install 6 Package(s)
Total download size: 596 k
Installed size: 1.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): perl-Digest-HMAC-1.01-22.el6.noarch.rpm | 22 kB 00:00
(2/6): perl-Digest-SHA1-2.12-2.el6.x86_64.rpm | 49 kB 00:00
(3/6): perl-Net-DNS-0.65-5.el6.x86_64.rpm | 232 kB 00:00
(4/6): perl-Razor-Agent-2.85-6.el6.x86_64.rpm | 119 kB 00:00
(5/6): perl-URI-1.40-2.el6.noarch.rpm | 117 kB 00:00
(6/6): pyzor-0.5.0-3.el6.noarch.rpm | 57 kB 00:00
——————————————————————————–
Total 129 kB/s | 596 kB 00:04
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-URI-1.40-2.el6.noarch 1/6
Installing : perl-Digest-SHA1-2.12-2.el6.x86_64 2/6
Installing : perl-Digest-HMAC-1.01-22.el6.noarch 3/6
Installing : perl-Net-DNS-0.65-5.el6.x86_64 4/6
Installing : perl-Razor-Agent-2.85-6.el6.x86_64 5/6
Installing : pyzor-0.5.0-3.el6.noarch 6/6
Verifying : perl-Digest-HMAC-1.01-22.el6.noarch 1/6
Verifying : perl-Net-DNS-0.65-5.el6.x86_64 2/6
Verifying : perl-Digest-SHA1-2.12-2.el6.x86_64 3/6
Verifying : perl-URI-1.40-2.el6.noarch 4/6
Verifying : perl-Razor-Agent-2.85-6.el6.x86_64 5/6
Verifying : pyzor-0.5.0-3.el6.noarch 6/6
Installed:
perl-Razor-Agent.x86_64 0:2.85-6.el6 pyzor.noarch 0:0.5.0-3.el6
Dependency Installed:
perl-Digest-HMAC.noarch 0:1.01-22.el6 perl-Digest-SHA1.x86_64 0:2.12-2.el6
perl-Net-DNS.x86_64 0:0.65-5.el6 perl-URI.noarch 0:1.40-2.el6
Complete!
2. Configuring Pyzor
[root@mail ]# mkdir /opt/zimbra/amavisd/.pyzor -p
[root@mail ]# chown zimbra:zimbra /opt/zimbra/amavisd/.pyzor
As the zimbra user
[root@mail ]# su zimbra
[zimbra@mail ]$ pyzor –homedir /opt/zimbra/amavisd/.pyzor discover
downloading servers from http://pyzor.sourceforge.net/cgi-bin/inform-servers-0-3-x
[zimbra@mail ]$
Update /opt/zimbra/data/spamassassin/localrules/sauser.cf
# pyzor
use_pyzor 1
pyzor_path /usr/bin/pyzor
pyzor_options –homedir /opt/zimbra/data/amavisd/.pyzor
# DNS lookups for pyzor can time out easily. Set the following line IF you want to give pyzor up to 20 seconds to respond
# may slow down email delivery
pyzor_timeout 20
[root@mail localrules]# chown -Rf zimbra:zimbra sauser.cf
3. Configuring Razor
[root@mail /]# mkdir /opt/zimbra/amavisd/.razor
[root@mail /]# chown -Rf zimbra:zimbra /opt/zimbra/amavisd/.razor
As the zimbra user
[zimbra@mail /]$ razor-admin -home=/opt/zimbra/data/amavisd/.razor -create
[zimbra@mail /]$ razor-admin -home=/opt/zimbra/data/amavisd/.razor -discover
[zimbra@mail /]$ razor-admin -home=/opt/zimbra/data/amavisd/.razor -register -user postmaster@domain.com
Register successful. Identity stored in /opt/zimbra/data/amavisd/.razor/identity-postmaster@domain.com
Update /opt/zimbra/data/spamassassin/localrules/sauser.cf
# razor
use_razor2 1
4. Update SpamAssassin scoring
Update /opt/zimbra/data/spamassassin/localrules/sauser.cf
ok_languages en es
ok_locales en es
trusted_networks 127. 192.168.
use_bayes 1
skip_rbl_checks 0
# pyzor
use_pyzor 1
pyzor_path /usr/bin/pyzor
# DNS lookups for pyzor can time out easily. Set the following line IF you want to give pyzor up to 20 seconds to respond
# may slow down email delivery
pyzor_timeout 20
# razor
use_razor2 1
score URIBL_BLACK 4.250
score RAZOR2_CHECK 3.250
score PYZOR_CHECK 3.250
score RP_MATCHES_RCVD -0.000
score BAYES_00 -1.000
score BAYES_20 1.000
score BAYES_50 1.500
score BAYES_60 1.800
score BAYES_80 2.100
score BAYES_90 2.500
score BAYES_99 2.900
score BAYES_999 3.800
5. Add custom rules from Kevin McGrail to your scores
As zimbra user:
cd /opt/zimbra/data/spamassassin/localrules
wget -N https://www.pccc.com/downloads/SpamAssassin/contrib/KAM.cf
zmamavisdctl restart
6. Enable DCC
[root@mail localrules]# mkdir -p /opt/zimbra/dcc-1.3.158
[root@mail localrules]# chown zimbra:zimbra /opt/zimbra/dcc-1.3.158
[root@mail localrules]# cd /opt/zimbra/
[root@mail localrules]# ln -s dcc-1.3.158 dcc
As zimbra user:
[zimbra@mail]$ cd /tmp
[zimbra@mail]$ mkdir dcc
[zimbra@mail]$ wget https://www.dcc-servers.net/dcc/source/dcc.tar.Z
[zimbra@mail]$ tar xfz dcc.tar.Z
[zimbra@mail]$ cd dcc-1.3.158
[zimbra@mail]$ mv * /opt/zimbra/dcc-1.3.158/
[zimbra@mail]$ ./configure –homedir=/opt/zimbra/dcc-1.3.158 –disable-sys-inst –with-uid=zimbra –disable-server –disable-dccifd –disable-dccm –with-updatedcc_pfile=/opt/zimbra/data/dcc –with-rundir=/opt/zimbra/data/dcc/run –bindir=/opt/zimbra/dcc/bin
[zimbra@mail]$ make
[zimbra@mail]$ make install
[zimbra@mail]$ cd /opt/zimbra/data
[zimbra@mail data]$ mkdir -p dcc/run
Update /opt/zimbra/data/spamassassin/localrules/sauser.cf
use_dcc 1
dcc_path /opt/zimbra/dcc/bin/dccproc
Update /opt/zimbra/data/spamassassin/localrules/v310.pre
loadplugin Mail::SpamAssassin::Plugin::DCC // Uncomment it
[zimbra@mail]$ zmamavisdctl restart
To see if it’s working with your spam .eml:
/opt/zimbra/zimbramon/bin/spamassassin -t -D < /tmp/sample_spam.eml
You should see the DCC_CHECK rule hit.
Install the SOUGHT rules:
cd /tmp
wget http://yerp.org/rules/GPG.KEY
su – zimbra
/opt/zimbra/zimbramon/bin/sa-update –import /tmp/GPG.KEY
Edit the file /opt/zimbra/libexec/zmsaupdate, and change the my $sa variable (~line 58) from:
my $sa=”/opt/zimbra/zimbramon/bin/sa-update -v –channel sought.rules.yerp.org –channel updates.spamassassin.org –gpgkey 6C6191E3 –allowplugins –refreshmirrors >/dev/null 2>&1″;
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1. Create /etc/yum.repos.d/epel.repo
[epel]
name=EPEL repository
baseurl=http://mirrors.kernel.org/fedora-epel/6/x86_64
enabled=1
gpgcheck=0
[root@mail] yum install pyzor perl-Razor-Agent
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
epel | 4.3 kB 00:00
epel/primary_db | 5.9 MB 00:29
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.
–> Running transaction check
—> Package perl-Razor-Agent.x86_64 0:2.85-6.el6 will be installed
–> Processing Dependency: perl(URI::Escape) for package: perl-Razor-Agent-2.85-6.el6.x86_64
–> Processing Dependency: perl(Net::DNS) for package: perl-Razor-Agent-2.85-6.el6.x86_64
—> Package pyzor.noarch 0:0.5.0-3.el6 will be installed
–> Running transaction check
—> Package perl-Net-DNS.x86_64 0:0.65-5.el6 will be installed
–> Processing Dependency: perl(Digest::HMAC_MD5) for package: perl-Net-DNS-0.65-5.el6.x86_64
—> Package perl-URI.noarch 0:1.40-2.el6 will be installed
–> Running transaction check
—> Package perl-Digest-HMAC.noarch 0:1.01-22.el6 will be installed
–> Processing Dependency: perl(Digest::SHA1) for package: perl-Digest-HMAC-1.01-22.el6.noarch
–> Running transaction check
—> Package perl-Digest-SHA1.x86_64 0:2.12-2.el6 will be installed
–> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
perl-Razor-Agent x86_64 2.85-6.el6 epel 119 k
pyzor noarch 0.5.0-3.el6 epel 57 k
Installing for dependencies:
perl-Digest-HMAC noarch 1.01-22.el6 base 22 k
perl-Digest-SHA1 x86_64 2.12-2.el6 base 49 k
perl-Net-DNS x86_64 0.65-5.el6 base 232 k
perl-URI noarch 1.40-2.el6 base 117 k
Transaction Summary
================================================================================
Install 6 Package(s)
Total download size: 596 k
Installed size: 1.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): perl-Digest-HMAC-1.01-22.el6.noarch.rpm | 22 kB 00:00
(2/6): perl-Digest-SHA1-2.12-2.el6.x86_64.rpm | 49 kB 00:00
(3/6): perl-Net-DNS-0.65-5.el6.x86_64.rpm | 232 kB 00:00
(4/6): perl-Razor-Agent-2.85-6.el6.x86_64.rpm | 119 kB 00:00
(5/6): perl-URI-1.40-2.el6.noarch.rpm | 117 kB 00:00
(6/6): pyzor-0.5.0-3.el6.noarch.rpm | 57 kB 00:00
——————————————————————————–
Total 129 kB/s | 596 kB 00:04
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-URI-1.40-2.el6.noarch 1/6
Installing : perl-Digest-SHA1-2.12-2.el6.x86_64 2/6
Installing : perl-Digest-HMAC-1.01-22.el6.noarch 3/6
Installing : perl-Net-DNS-0.65-5.el6.x86_64 4/6
Installing : perl-Razor-Agent-2.85-6.el6.x86_64 5/6
Installing : pyzor-0.5.0-3.el6.noarch 6/6
Verifying : perl-Digest-HMAC-1.01-22.el6.noarch 1/6
Verifying : perl-Net-DNS-0.65-5.el6.x86_64 2/6
Verifying : perl-Digest-SHA1-2.12-2.el6.x86_64 3/6
Verifying : perl-URI-1.40-2.el6.noarch 4/6
Verifying : perl-Razor-Agent-2.85-6.el6.x86_64 5/6
Verifying : pyzor-0.5.0-3.el6.noarch 6/6
Installed:
perl-Razor-Agent.x86_64 0:2.85-6.el6 pyzor.noarch 0:0.5.0-3.el6
Dependency Installed:
perl-Digest-HMAC.noarch 0:1.01-22.el6 perl-Digest-SHA1.x86_64 0:2.12-2.el6
perl-Net-DNS.x86_64 0:0.65-5.el6 perl-URI.noarch 0:1.40-2.el6
Complete!
2. Configuring Pyzor
[root@mail ]# mkdir /opt/zimbra/amavisd/.pyzor -p
[root@mail ]# chown zimbra:zimbra /opt/zimbra/amavisd/.pyzor
As the zimbra user
[root@mail ]# su zimbra
[zimbra@mail ]$ pyzor –homedir /opt/zimbra/amavisd/.pyzor discover
downloading servers from http://pyzor.sourceforge.net/cgi-bin/inform-servers-0-3-x
[zimbra@mail ]$
Update /opt/zimbra/data/spamassassin/localrules/sauser.cf
# pyzor
use_pyzor 1
pyzor_path /usr/bin/pyzor
pyzor_options –homedir /opt/zimbra/data/amavisd/.pyzor
# DNS lookups for pyzor can time out easily. Set the following line IF you want to give pyzor up to 20 seconds to respond
# may slow down email delivery
pyzor_timeout 20
[root@mail localrules]# chown -Rf zimbra:zimbra sauser.cf
3. Configuring Razor
[root@mail /]# mkdir /opt/zimbra/amavisd/.razor
[root@mail /]# chown -Rf zimbra:zimbra /opt/zimbra/amavisd/.razor
As the zimbra user
[zimbra@mail /]$ razor-admin -home=/opt/zimbra/data/amavisd/.razor -create
[zimbra@mail /]$ razor-admin -home=/opt/zimbra/data/amavisd/.razor -discover
[zimbra@mail /]$ razor-admin -home=/opt/zimbra/data/amavisd/.razor -register -user postmaster@domain.com
Register successful. Identity stored in /opt/zimbra/data/amavisd/.razor/identity-postmaster@domain.com
Update /opt/zimbra/data/spamassassin/localrules/sauser.cf
# razor
use_razor2 1
4. Update SpamAssassin scoring
Update /opt/zimbra/data/spamassassin/localrules/sauser.cf
ok_languages en es
ok_locales en es
trusted_networks 127. 192.168.
use_bayes 1
skip_rbl_checks 0
# pyzor
use_pyzor 1
pyzor_path /usr/bin/pyzor
# DNS lookups for pyzor can time out easily. Set the following line IF you want to give pyzor up to 20 seconds to respond
# may slow down email delivery
pyzor_timeout 20
# razor
use_razor2 1
score URIBL_BLACK 4.250
score RAZOR2_CHECK 3.250
score PYZOR_CHECK 3.250
score RP_MATCHES_RCVD -0.000
score BAYES_00 -1.000
score BAYES_20 1.000
score BAYES_50 1.500
score BAYES_60 1.800
score BAYES_80 2.100
score BAYES_90 2.500
score BAYES_99 2.900
score BAYES_999 3.800
5. Add custom rules from Kevin McGrail to your scores
As zimbra user:
cd /opt/zimbra/data/spamassassin/localrules
wget -N https://www.pccc.com/downloads/SpamAssassin/contrib/KAM.cf
zmamavisdctl restart
6. Enable DCC
[root@mail localrules]# mkdir -p /opt/zimbra/dcc-1.3.158
[root@mail localrules]# chown zimbra:zimbra /opt/zimbra/dcc-1.3.158
[root@mail localrules]# cd /opt/zimbra/
[root@mail localrules]# ln -s dcc-1.3.158 dcc
As zimbra user:
[zimbra@mail]$ cd /tmp
[zimbra@mail]$ mkdir dcc
[zimbra@mail]$ wget https://www.dcc-servers.net/dcc/source/dcc.tar.Z
[zimbra@mail]$ tar xfz dcc.tar.Z
[zimbra@mail]$ cd dcc-1.3.158
[zimbra@mail]$ mv * /opt/zimbra/dcc-1.3.158/
[zimbra@mail]$ ./configure –homedir=/opt/zimbra/dcc-1.3.158 –disable-sys-inst –with-uid=zimbra –disable-server –disable-dccifd –disable-dccm –with-updatedcc_pfile=/opt/zimbra/data/dcc –with-rundir=/opt/zimbra/data/dcc/run –bindir=/opt/zimbra/dcc/bin
[zimbra@mail]$ make
[zimbra@mail]$ make install
[zimbra@mail]$ cd /opt/zimbra/data
[zimbra@mail data]$ mkdir -p dcc/run
Update /opt/zimbra/data/spamassassin/localrules/sauser.cf
use_dcc 1
dcc_path /opt/zimbra/dcc/bin/dccproc
Update /opt/zimbra/data/spamassassin/localrules/v310.pre
loadplugin Mail::SpamAssassin::Plugin::DCC // Uncomment it
[zimbra@mail]$ zmamavisdctl restart
To see if it’s working with your spam .eml:
/opt/zimbra/zimbramon/bin/spamassassin -t -D < /tmp/sample_spam.eml
You should see the DCC_CHECK rule hit.
Install the SOUGHT rules:
cd /tmp
wget http://yerp.org/rules/GPG.KEY
su – zimbra
/opt/zimbra/zimbramon/bin/sa-update –import /tmp/GPG.KEY
Edit the file /opt/zimbra/libexec/zmsaupdate, and change the my $sa variable (~line 58) from:
my $sa=”/opt/zimbra/zimbramon/bin/sa-update -v –channel sought.rules.yerp.org –channel updates.spamassassin.org –gpgkey 6C6191E3 –allowplugins –refreshmirrors >/dev/null 2>&1″;