Mail サーバー : Postfix + Clamav + Amavisd2025/12/02 |
|
Postfix と Clamav を連携させて 送受信メールをリアルタイムスキャンできるように設定します。 |
|
| [1] | |
| [2] | Amavisd および Clamav Server をインストールします。 |
|
mail:~ #
mail:~ # zypper -n install amavisd-new perl-Digest-SHA1 perl-IO-stringy systemctl enable --now clamd |
| [3] | SELinux を有効にしている場合は、ポリシーの変更が必要です。 |
|
mail:~ # setsebool -P antivirus_can_scan_system on
mail:~ #
vi amavis.te # create new
module amavis 1.0;
require {
type var_spool_t;
type antivirus_t;
class dir { add_name create remove_name rmdir setattr write };
class sock_file { create unlink };
class file { create link rename setattr unlink write };
}
#============= antivirus_t ==============
allow antivirus_t var_spool_t:dir { add_name create remove_name rmdir setattr write };
allow antivirus_t var_spool_t:file { create link setattr unlink write };
allow antivirus_t var_spool_t:file rename;
allow antivirus_t var_spool_t:sock_file { create unlink };
checkmodule -m -M -o amavis.mod amavis.te mail:~ # semodule_package --outfile amavis.pp --module amavis.mod mail:~ # semodule -i amavis.pp |
| [4] | Amavisd を設定して起動します。 |
|
mail:~ #
vi /etc/amavisd.conf # 23行目 : 自ドメイン名に変更 $mydomain = ' srv.world ';
# 167行目 : コメント解除して自ホスト名に変更 $myhostname = ' mail.srv.world ';
systemctl enable --now amavis |
| [5] | Postfix の設定です。 |
|
mail:~ #
vi /etc/postfix/main.cf # 709行目 : 追記 content_filter = smtp-amavis:[127.0.0.1]:10024
mail:~ #
vi /etc/postfix/master.cf # 最終行に追記
smtp-amavis unix - - n - 2 smtp
-o smtp_data_done_timeout=1200
-o smtp_send_xforward_command=yes
-o smtp_dns_support_level=disabled
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] | 以上で設定完了です。 送受信メールには以下のようなヘッダーが付加されます。もしウィルスが検知された場合は削除され、クライアントには配送されません。 |
|
| Sponsored Link |
|
|