Postfix + ClamAV + SpamAssassin Ubuntu 18.04.1 2019/12
ClamAVのインストール
freshclamを実行する
/etc/logrotate.d/clamav-freshclam
/var/log/clamv/
SpamAssassinのインストール
Amavisのインストール
ClamAVとAMAVISのユーザ設定
razorの設定
Amavisの設定
/etc/amavis/conf.d/05-node_id
/etc/amavis/conf.d/15-content_filter_mode
Postfixの設定
/etc/postfix/main.cf
/etc/postfix/master.cf
Amavisの起動とPostfixの再起動
メーラーで送受信を行い、メッセージソースを確認する。
ClamAVのインストール
apt-get install clamav clamav-daemon
freshclamを実行する
freshclam
ERROR: /var/log/clamav/freshclam.log is locked by another process
ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).
エラーが出るので設定を変更する。/etc/logrotate.d/clamav-freshclam
#create 640 clamav adm create 640 clamav clamavログファイルを更新する。
/var/log/clamv/
mv freshclam.log freshclam.log.old freshclam作成されたログファイルを確認する。
SpamAssassinのインストール
apt-get install spamassassin apt-get install libnet-dns-perl libmail-spf-perl pyzor razor apt-get install arj bzip2 cabextract cpio file gzip lhasa nomarch pax rar unrar unzip zip
Amavisのインストール
apt-get install amavisd-new起動に失敗するが、そのまま進む。
ClamAVとAMAVISのユーザ設定
adduser clamav amavis adduser amavis clamav
razorの設定
su - amavis -s /bin/bash razor-admin -create razor-admin -register
Amavisの設定
/etc/amavis/conf.d/05-node_id
#$myhostname = "mail.example.com";$myhostnameに実際のホスト名を指定する。
/etc/amavis/conf.d/15-content_filter_mode
... #@bypass_virus_checks_maps = ( # \%bypass_virus_checks, \@bypass_virus_checks_acl, \$bypass_virus_checks_re); ... #@bypass_spam_checks_maps = ( # \%bypass_spam_checks, \@bypass_spam_checks_acl, \$bypass_spam_checks_re); ...上記4行のコメントアウトを外して、ウィルスチェックとスパムチェックを有効にする。
Postfixの設定
/etc/postfix/main.cf
content_filter = smtp-amavis:[127.0.0.1]:10024PostfixからAmavisへのポート指定:10024
/etc/postfix/master.cf
...
pickup unix n - - 60 1 pickup
# 追加 start
-o content_filter=
-o receive_override_options=no_header_body_checks
# 追加 end
cleanup unix n - - - 0 cleanup
...
# 以下を末尾に追加
smtp-amavis unix - - - - 2 smtp
-o smtp_data_done_timeout=1200
-o smtp_send_xforward_command=yes
-o disable_dns_lookups=yes
-o max_use=20
127.0.0.1:10025 inet n - - - - smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-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 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
Amavisの起動とPostfixの再起動
systemctl start amavis systemctl status amavis systemctl restart postfix systemctl status postfix
メーラーで送受信を行い、メッセージソースを確認する。