Mail Server : Postfix + Clamav + Amavisd2019/11/21 |
Configure Virus-Scanning for E-Mails with Postfix + Clamav.
|
|
[1] | |
[2] | Install Amavisd and Clamav Server. |
[root@mail ~]#
dnf -y install amavis clamd perl-Digest-SHA1 perl-IO-stringy
[root@mail ~]#
vi /etc/clamd.d/scan.conf # line 8: comment out # Example
# line 14: uncomment LogFile /var/log/clamd.scan # line 74: uncomment PidFile /var/run/clamd.scan/clamd.pid # line 78: uncomment TemporaryDirectory /var/tmp # line 93: uncomment LocalSocket /var/run/clamd.scan/clamd.sock touch /var/log/clamd.scan [root@mail ~]# chown clamscan. /var/log/clamd.scan [root@mail ~]# systemctl enable --now clamd@scan |
[3] | If SELinux is enabled, add rules to start Clamav Server like follows. |
[root@mail ~]# restorecon -v /var/log/clamd.scan [root@mail ~]# setsebool -P antivirus_can_scan_system on |
[4] | Configure Amavisd. |
[root@mail ~]#
vi /etc/amavisd/amavisd.conf # line 23: change to the own domain name $mydomain = ' srv.world ';
# line 155: uncomment and change to the own hostname $myhostname = ' mail.srv.world ';
# line 157,158: uncomment $notify_method = 'smtp:[127.0.0.1]:10025'; $forward_method = 'smtp:[127.0.0.1]:10025'; systemctl enable --now amavisd |
[5] | Configure Postfix. |
[root@mail ~]#
vi /etc/postfix/main.cf # add follows to the end content_filter=smtp-amavis:[127.0.0.1]:10024
[root@mail ~]#
vi /etc/postfix/master.cf # add follows to the end smtp-amavis unix - - n - 2 smtp -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes 127.0.0.1:10025 inet n - n - - smtpd -o content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o smtpd_restriction_classes= -o smtpd_client_restrictions= -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks=127.0.0.0/8 -o strict_rfc821_envelopes=yes -o smtpd_error_sleep_time=0 -o smtpd_soft_error_limit=1001 -o smtpd_hard_error_limit=1000 systemctl restart postfix |
[6] | That' OK all. [X-Virus-Scanned: ***] lines are added in the header section of emails after this configuration and emails with known Virus will not sent to Clients like following email logs. |
Nov 6 21:21:33 mail postfix/pickup[1787]: 781F86A8D9: uid=1000 from=<fedora> Nov 6 21:21:33 mail postfix/cleanup[1999]: 781F86A8D9: message-id=<20191106082133.781F86A8D9@mail.srv.world> Nov 6 21:21:33 mail postfix/qmgr[1788]: 781F86A8D9: from=<fedora@srv.world>, size=1067, nrcpt=1 (queue active) Nov 6 21:21:33 mail clamd[1789]: /var/spool/amavisd/tmp/amavis-20191106T171232-01897-FhzhpBI_/parts/p004: Eicar-Test-Signature FOUND Nov 6 21:21:33 mail clamd[1789]: /var/spool/amavisd/tmp/amavis-20191106T171232-01897-FhzhpBI_/parts/p002: Eicar-Test-Signature FOUND Nov 6 21:21:33 mail amavis[1897]: (01897-02) Blocked INFECTED (Eicar-Test-Signature) {DiscardedInbound,Quarantined}, [127.0.0.1] <fedora@srv.world> -> <redhat@srv.world>, Message-ID: <20191106082133.781F86A8D9@mail.srv.world>, mail_id: RWk5af6D8pJ2, Hits: -, size: 1067, 88 ms Nov 6 21:21:33 mail postfix/smtp[2000]: 781F86A8D9: to=<redhat@srv.world>, orig_to=<fedora@mail.virtual.host>, relay=127.0.0.1[127.0.0.1]:10024, delay=0.18, delays=0.07/0.02/0/0.09, dsn=2.7.0, status=sent (250 2.7.0 Ok, discarded, id=01897-02 - INFECTED: Eicar-Test-Signature) Nov 6 21:21:33 mail postfix/qmgr[1788]: 781F86A8D9: removed |
Sponsored Link |
|