May 18 2011

amavis, clamav ir spamassassin kartu su postfix’u

Category: how-to,ITmop @ 13.45

Sistema Centos 5.5 x64. Aprašau kaip susikonfigūruoti minėtus dalykus, kad veiktų. Wiki.centos.org tutorial’as truputį nepilnas ir neveikia out of the box.

Visur naudoju vim editorių, kas nemoka/nenori naudotis, pasikeiskit komandą vim į jums patinkantį editorių (nano, mcedit ar pan.).

  • wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm (linką randam čia rpmforge).
  • rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt
  • rpm -i rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
  • yum –enablerepo=rpmforge,rpmforge-extras install amavisd-new clamav clamav-devel clamd spamassassin
  • gpasswd -a clam amavis
  • chkconfig –levels 234 clamd on
  • chkconfig –levels 234 spamassassin on
  • vim /etc/clamd.conf

įsitikinam, kad atkomentuota:

LocalSocket /var/run/clamav/clamd.sock

užkomentuojam:

# TCPSocket 3310
  • vim /etc/amavisd.conf
  • Norint disable’int antivirusą arba antispamą, atkomentuojam:
### /etc/amavisd.conf:
#
# To disable virus or spam checks, uncomment the following:
#
# @bypass_virus_checks_maps = (1);  # controls running of anti-virus code
# @bypass_spam_checks_maps  = (1);  # controls running of anti-spam code
# $bypass_decode_parts = 1;         # controls running of decoders & dearchivers
  • Šių dalykų galima nekeisti:
$max_servers = 2;                   # num of pre-forked children (2..30 is common), -m
$daemon_user  = "amavis";           # (no default;  customary: vscan or amavis), -u
$daemon_group = "amavis";           # (no default;  customary: vscan or amavis), -g
...
$inet_socket_port = 10024;          # listen on this local TCP port(s)
...
# $notify_method  = 'smtp:[127.0.0.1]:10025';
# $forward_method = 'smtp:[127.0.0.1]:10025';  # set to undef with milter!
  • Šiuos dalykus atkomentuojam ir pakeičiam pagal serverio nustatymus:
$mydomain = 'example.com';                  # Keičiam: į savo domeną
$MYHOME = '/var/amavis';                    # atkomentuojam
$helpers_home = "$MYHOME/var";              # atkomentuojam
$lock_file = "$MYHOME/var/amavisd.lock";    # atkomentuojam
$pid_file  = "$MYHOME/var/amavisd.pid";     # atkomentuojam
$myhostname = 'mail.example.com';           # atkomentuojam ir pakeičiam į savo hostname'ą (turi būti FQDN)
  • Susirandam ir atkomentuojam:
### http://www.clamav.net/
['ClamAV-clamd',
  \&ask_daemon, ["CONTSCAN {}\n", "/var/run/clamav/clamd.sock"],
  qr/\bOK$/, qr/\bFOUND$/,
  qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
# # NOTE: run clamd under the same user as amavisd, or run it under its own
# #   uid such as clamav, add user clamav to the amavis group, and then add
# #   AllowSupplementaryGroups to clamd.conf;
# # NOTE: match socket name (LocalSocket) in clamav.conf to the socket name in
# #   this entry; when running chrooted one may prefer socket "$MYHOME/clamd".

/var/run/clamav/clamd.sock turi sutapti su clamd.conf faile nurodyta reikšme (žr. aukščiau).

visus kitus antivirusus galima užkomentuoti/ištrinti

  • tam, kad gauti spaminius laiškus su pakeistu subject’u, atkomentuojam ir pakeičiam:
$final_virus_destiny      = D_DISCARD;
$final_banned_destiny     = D_BOUNCE;
$final_spam_destiny       = D_PASS;
$final_bad_header_destiny = D_PASS;
  • pridedam eilutę:
$sa_spam_modifies_subj = 1;
  • vim /etc/postfix/master.cf
  • pridedam:
amavisfeed unix    -       -       n        -      2     lmtp
    -o lmtp_data_done_timeout=1200
    -o lmtp_send_xforward_command=yes
    -o disable_dns_lookups=yes
    -o max_use=20
127.0.0.1:10025 inet n    -       n       -       -     smtpd
    -o content_filter=
    -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 smtpd_restriction_classes=
    -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,no_milters,no_address_mappings
    -o local_header_rewrite_clients=
    -o smtpd_milters=
    -o local_recipient_maps=
    -o relay_recipient_maps=
  • postfix reload
  • jeigu viskas ok, pridedam gale /etc/postfix/main.cf
content_filter=amavisfeed:[127.0.0.1]:10024
  • postfix reload
  • sa-update
  • freshclam
  • nepadarius sa-update ir freshclam sistema neveikia, čia ir buvau strigęs kol išsiaiškinau
  • /etc/init.d/clamd start
  • /etc/init.d/amavisd start
  • /etc/init.d/spamassassin start
  • jeigu viskas ok, turi telnetintis abiem portais:
# telnet localhost 10024Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 [127.0.0.1] ESMTP amavisd-new service ready

# telnet localhost 10025
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.example.com ESMTP Postfix
  • vim /etc/cron.d/sa-update atkomentuojam:
10 4 * * * root /usr/share/spamassassin/sa-update.cron 2>&1 | tee -a /var/log/sa-update.log
  • tail -f /var/log/maillog

Viskas. Check’as veikia, laiškai žymimi. Klausimai ir pastabos – komentaruose.

Buk socialus, pasidalink!
Patiko? Prenumeruok RSS!

Palik komentarą