はじめての自宅サーバ構築 - Fedora/CentOS - Last Update 2008/07/25
It opened to 2004/09/19.
当サイトはFedora9で運用しています
Visitors
Pageviews
Today(IP/PV)
3,374,111
12,762,005
1,269/8,627
動作確認 [ FC5 / FC6 / Fedora7 / Fedora8 / Fedora9 / CentOS4 / CentOS5 ]
  1. はじめに・・・
  2. 既に『AntiVir MailGate』導入済みの方へ・・・
    『AntiVir MailGate』のアンインストール
  3. amavisd-newのインストール
    FedoraCore5 / FedoraCore6 / Fedora7 / Fedora8 / Fedora9 / CentOS4 の場合
    CentOS5 の場合
  4. 関連ファイルの設定
  5. amavisdサービス関連の起動と登録
  6. ウィルス定義ファイルの更新
  7. clamav+amavisdの動作確認

■ はじめに・・・

メールウイルス検出・駆除(AntiVir MailGate)』を使用していたのですが、無料で使用できなくなってしまった様です。
最新版では個人使用で『AntiVir Workstation』が無料で使えるのですが、今後また同様な事が起こらないとも限らないので控える事としました。
また、当サイトで『アンチウィルスソフトの導入(Clam AntiVirus)』を紹介しています。このエンジン+データベースを利用してメールチェックを行う事にしました。

■ 既に『AntiVir MailGate』導入済みの方へ・・・

既に『メールウイルス検出・駆除(AntiVir MailGate)』を導入している方は、以下の手順を踏んでアンインストールして下さい。
導入していない方は当該項目を飛ばしてください。

■ 『AntiVir MailGate』のアンインストール

postfixサービスの停止
# /etc/rc.d/init.d/postfix stop
postfix を停止中:                                          [  OK  ]
AntiVir MailGateサービスの停止
# /etc/rc.d/init.d/avgate stop
Shutting down AntiVir MailGate service:                    [  OK  ]

postfix関連設定ファイルのAntiVir Mailgate部分を削除
# vi /etc/postfix/main.cf
# AntiVir MailGate
content_filter = smtp:127.0.0.1:10024

# vi /etc/postfix/master.cf
localhost:smtp-backdoor inet n - n - - smtpd -o content_filter=

# vi /etc/services
antivir         10024/tcp                       # Port for avgated
smtp-backdoor   10025/tcp                       # Port for postfix backdoor


AntiVir MailGate関連ファイル削除
# chkconfig --del avgate
# rm -rf /usr/lib/AntiVir/
# rm -rf /var/spool/avmailgate
# rm -f /usr/sbin/avgated
# rm -f /usr/sbin/avgatefwd
# rm -f /usr/sbin/avmailgate
# rm -f /etc/avmailgate.*
# rm -f /usr/share/man/man5/avmailgate.conf.5
# rm -f /usr/share/man/man8/avmailgate.8
# rm -f /etc/rc.d/init.d/avgate
# rm -f /etc/rc.d/rc0.d/*avmailgate
# rm -f /etc/rc.d/rc1.d/*avmailgate
# rm -f /etc/rc.d/rc2.d/*avmailgate
# rm -f /etc/rc.d/rc3.d/*avmailgate
# rm -f /etc/rc.d/rc4.d/*avmailgate
# rm -f /etc/rc.d/rc5.d/*avmailgate
# rm -f /etc/rc.d/rc6.d/*avmailgate

■ amavisd-newのインストール

■ FedoraCore5 / FedoraCore6 / Fedora7 / Fedora8 / Fedora9 / CentOS4 の場合

amavisd-newのインストール
# yum -y install amavisd-new

■ CentOS5 の場合

dagリポジトリに追加
(新規作成ではありません。必ず『アンチウィルスソフトの導入(Clam AntiVirus)』を参照下さい。
また、インストール順序も厳守してください。「Clam AntiVirus」→「clamav+amavisd」)
# vi /etc/yum.repos.d/CentOS-Dag.repo
[dag]
name=CentOS-$releasever - Dag
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el$releasever/en/$basearch/dag
URLを追加
        http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
リポジトリを有効にする
enabled=1
gpgkey=http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt

amavisd-newのインストール
# yum -y install amavisd-new

インストールが完了したら、dag用のレポジトリ無効化(今後のパッケージ混在に不整合を起こさない様にする為)
# vi /etc/yum.repos.d/dag.repo
[dag]
name=CentOS-$releasever - Dag
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el$releasever/en/$basearch/dag
        http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=0
gpgkey=http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt

■ 関連ファイルの設定

amavisd設定ファイルの変更
【FedoraCore5 / FedoraCore6 / Fedora7 / Fedora8 / Fedora9 / CentOS4 の場合】
# vi /etc/amavisd/amavisd.conf

【CentOS5 の場合】
# vi /etc/amavisd.conf

自ドメイン名を設定
$mydomain = 'kajuhome.com';   # a convenient default for other settings

ウィルスメール検知時の通知先メールアドレスを設定
$virus_admin               = 'webmaster@kajuhome.com'; # notifications recip.
スパムメール検知時の通知先メールアドレスを設定(以下の行を追加)
$spam_admin                = 'webmaster@kajuhome.com';
通知先をコメントアウト(削除)すれば、通知されなくなります

コメントを削除し自ホスト名を設定
$myhostname = 'fedora.kajuhome.com';  # must be a fully-qualified domain name!

コメントを削除して有効にする
$notify_method  = 'smtp:[127.0.0.1]:10025';
$forward_method = 'smtp:[127.0.0.1]:10025';  # set to undef with milter!

各種メール受信時の動作(以下のコメント参照)
$final_virus_destiny      = D_DISCARD;
$final_banned_destiny     = D_BOUNCE;
$final_spam_destiny       = D_DISCARD;
$final_bad_header_destiny = D_PASS;

属性名の意味
final_virus_destiny      :ウィルスメールの最終処理
final_banned_destiny     :禁止されたメールの最終処理
final_spam_destiny       :SPAMのメールの最終処理
final_bad_header_destiny :ASCII以外の文字がヘッダに含まれるメールの最終処理

属性値の意味
D_DISCARD  :受信者に配送されず、送信者には通知しない。
D_BOUNCE   :受信者に配送されず、送信者には未配送を通知する。(例外あり)
D_REJECT   :受信者に配送されず、送信者には未配送を通知する。
D_PASS     :無条件に配送される。



postfix関連ファイルの変更
# vi /etc/postfix/main.cf
以下を最終行へ追加
# amavis
content_filter=smtp-amavis:[127.0.0.1]:10024

# vi /etc/postfix/master.cf
pickup    fifo  n       -       n       60      1       pickup
以下を追加
smtp-amavis unix -      -       n       -       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  -       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


サービスファイルの変更
# vi /etc/services
afs3-rmtsys     7009/tcp                        # remote cache manager service
afs3-rmtsys     7009/udp                        # remote cache manager service
sd              9876/tcp                        # Session Director
sd              9876/udp                        # Session Director
ポート指定の追加(2行)
amavis          10024/tcp                       # Port for amavis
smtp-backdoor   10025/tcp                       # Port for postfix backdoor
amanda          10080/tcp                       # amanda backup services
amanda          10080/udp                       # amanda backup services
pgpkeyserver    11371/tcp                       # PGP/GPG public keyserver
pgpkeyserver    11371/udp                       # PGP/GPG public keyserver

■ amavisdサービス関連の起動

amavisdサービス関連の起動と登録
# /etc/rc.d/init.d/amavisd start
amavisd を起動中:                                          [  OK  ]

「clamd.amavisd」起動は【FedoraCore】のみ
# /etc/rc.d/init.d/clamd.amavisd start
clamd.amavisd を起動中:                                    [  OK  ]

 postfixを起動(再起動)する
postfixが起動している方は再起動「restart」or「reload」して下さい。
# /etc/rc.d/init.d/postfix start
postfix を起動中:                                          [  OK  ]


amavisをサービスに追加
# chkconfig --add amavisd

amavisを自動起動に設定
# chkconfig amavisd on

amavisdの自動起動確認
# chkconfig --list amavisd
amavisd         0:off   1:off   2:on    3:on    4:on    5:on    6:off


clamd.amavisdをサービスに追加
# chkconfig --add clamd.amavisd

clamd.amavisdを自動起動に設定
# chkconfig clamd.amavisd on

clamd.amavisdの自動起動確認
# chkconfig --list clamd.amavisd
clamd.amavisd   0:off   1:off   2:on    3:on    4:on    5:on    6:off

■ ウィルス定義ファイルの更新

ウィルス定義ファイルは『アンチウィルスソフトの導入(Clam AntiVirus)』のウィルス定義ファイルを使用しています。
Clam AntiVirusのウィルス定義ファイル最新化」をご参照下さい。

■ clamav+amavisdの動作確認

  1. 試験用のウイルス(無害)をeicarよりダウンロード。
    (試験ファイルは2006年08月30日時点で「eicar.com」「eicar.com.txt」「eicar_com.zip」「eicarcom2.zip」の4つが存在します。)
  2. ダウンロードした試験用のウイルスをメールソフトに添付してサーバのアカウントから外部のメールアドレス宛に送信。
  3. 上記手順と同様に外部のアカウントからサーバのアカウント宛に送信。
  4. いずれも試験用のウイルスを添付したメールは送信先には届かず、設定した通知先のメールアドレスに以下の様なメールが届けば動作しています。
以下が、設定した通知先のメールアドレスに届いた内容

A virus was found: Eicar-Test-Signature

Banned name: multipart/mixed | application/x-zip-compressed,.zip,eicarcom2.zip
  | .zip,eicar_com.zip | .asc,eicar.com
Scanner detecting a virus: ClamAV-clamd

Content type: Virus (9,0)
Internal reference code for the message is 14952-02/nJ21PMVzLHXo

First upstream SMTP client IP address: [xxx.xxx.xxx.xxx] xxx.yyy.zzz.com

Return-Path: <abcdef@yyy.zzz.com>
Message-ID: <20060905104025.25A7.abcdef@yyy.zzz.com>
X-Mailer: Becky! ver. 2.25.01 [ja]
Subject: =?ISO-2022-JP?B?GyRCJSYlIyVrJTklYSE8JWs7bjgzGyhC?=
Not quarantined.

Notification to sender will not be mailed.

The message WAS NOT relayed to:
<linux@kajuhome.com>:
   254 2.7.1 Ok, discarded, id=14952-02 - VIRUS: Eicar-Test-Signature

Virus scanner output:
  p005: Eicar-Test-Signature FOUND

また、サーバのログ「/var/log/maillog」にはウィルス検出したメッセージが以下の様に記録されています。

Sep 5 10:41:19 www amavis[14952]: (14952-02) Blocked INFECTED (Eicar-Test-Signature), [xxx.xxx.xxx.xxx] <abcdef@yyy.zzz.com> -> <linux@kajuhome.com>, Message-ID: <20060905104025.25A7.abcdef@yyy.zzz.com>, mail_id: nJ21PMVzLHXo, Hits: -, 353 ms

Sep 5 10:41:19 www postfix/smtp[15737]: D970C1000E4: to=<linux@kajuhome.com>, relay=127.0.0.1[127.0.0.1], delay=1, status=sent (254 2.7.1 Ok, discarded, id=14952-02 - VIRUS: Eicar-Test-Signature)

Sep 5 10:41:19 www postfix/qmgr[6115]: D970C1000E4: removed


備考)スパムメールを受信した時は、設定した通知先のメールアドレスへ以下の様な内容が送られてきます。

Internal reference code for the message is 24408-02/kCk8jOMSTSek

First upstream SMTP client IP address: [xxx.xxx.xxx.xxx]
  smtp.mail.yyy.zzz.com

Return-Path: <abcdef@yyy.zzz.com>
Message-ID: <20060905141023.3582.abcdef@yyy.zzz.com>
X-Mailer: Becky! ver. 2.25.01 [ja]
Subject: =?ISO-2022-JP?B?GyRCJTklUSVgJWEhPCVrO244MxsoQg==?=
Not quarantined.

The message WAS NOT relayed to:
<linux@kajuhome.com>:
   254 2.7.1 Ok, discarded, id=24408-02 - SPAM

SpamAssassin report:
Spam detection software, running on the system "fedora.kajuhome.com", has
identified this incoming email as possible spam.  The original message
has been attached to this so you can view it (if it isn't spam) or label
similar future email.  If you have any questions, see
the administrator of that system for details.

Content preview:  http://love-match.bz/pc/07 [...] 

Content analysis details:   (12.9 points, 5.0 required)

 pts rule name              description
---- ---------------------- --------------------------------------------------
-0.0 NO_RELAYS              Informational: message was not relayed via SMTP
 1.5 RAZOR2_CF_RANGE_E8_51_100 Razor2 gives engine 8 confidence level
                            above 50%
                            [cf: 100]
 0.5 RAZOR2_CF_RANGE_51_100 Razor2 gives confidence level above 50%
                            [cf: 100]
 1.4 DNS_FROM_RFC_POST      RBL: Envelope sender in
                            postmaster.rfc-ignorant.org
 3.3 URIBL_AB_SURBL         Contains an URL listed in the AB SURBL blocklist
                            [URIs: love-match.bz]
 3.4 URIBL_JP_SURBL         Contains an URL listed in the JP SURBL blocklist
                            [URIs: love-match.bz]
 3.6 URIBL_SC_SURBL         Contains an URL listed in the SC SURBL blocklist
                            [URIs: love-match.bz]
-0.0 NO_RECEIVED            Informational: message has no Received headers
-0.8 AWL                    AWL: From: address is in the auto white-list

■ 広告

ページ先頭へ

Copyright(©)2004-2008 First home server construction. All Right Reserved.