提供:すだちWiki
移動先: 案内検索

ヘルプ:メールサーバーでウイルスチェック(Postfix + Clamav + Amavisd)(AlmaLinux)

メインページ > ヘルプ:目次 > ヘルプ:自宅サーバー構築(AlmaLinux)  > メールサーバーでウイルスチェック(Postfix + Clamav + Amavisd)(AlmaLinux)

Amavisd および Clamav Server をインストール

インストール

  • EPEL および PowerTools (デフォルト無効) からインストール
[root@host4 ~]# dnf --enablerepo=epel -y install amavisd-new clamd perl-Digest-SHA1 perl-IO-stringy

Clamav Server 設定ファイル編集

[root@host4 ~]# vi /etc/clamd.d/scan.conf
# 8行目:コメントにする
#Example
# 14行目:コメント解除
LogFile /var/log/clamd.scan
# 74行目:コメント解除
PidFile /run/clamd.scan/clamd.pid
# 78行目:コメント解除
TemporaryDirectory /var/tmp
# 93行目:コメント解除
LocalSocket /run/clamd.scan/clamd.sock

ログ設定と起動

[root@host4 ~]# touch /var/log/clamd.scan

[root@host4 ~]# chown clamscan. /var/log/clamd.scan

[root@host4 ~]# systemctl start clamd@scan

[root@host4 ~]# systemctl enable clamd@scan

Amavisd を設定して起動

[root@host4 ~]# vi /etc/amavisd/amavisd.conf
# 23行目:自ドメイン名に変更
$mydomain = 'sudachi.jp';
# 155行目:コメント解除して自ホスト名に変更
$myhostname = 'mail.sudachi.jp';
# 157,158行目:コメント解除
$notify_method = 'smtp:[127.0.0.1]:10025';
$forward_method = 'smtp:[127.0.0.1]:10025';

[root@host4 ~]# systemctl start amavisd

[root@host4 ~]# systemctl enable amavisd
Created symlink /etc/systemd/system/multi-user.target.wants/amavisd.service → /usr/lib/systemd/system/amavisd.service.

Postfix の設定

[root@host4 ~]# vi /etc/postfix/main.cf
# 最終行に追記
content_filter=smtp-amavis:[127.0.0.1]:10024
[root@host4 ~]# vi /etc/postfix/master.cf
# 最終行に追記
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
[root@host4 ~]# systemctl restart postfix