業務用エアコン関連の技術情報、エラーコード、環境問題対策に関する別サイト「エアコンの安全な修理・適切なフロン回収」

Debian11.11 : Anti-virus(Clamav) , Mail Server

1. Antivirus software Clamav installed

Install Clam AntiVirus, a free anti-virus software for Linux, as an anti-virus measure.
By installing this anti-virus software, you can not only scan the entire server for viruses, but also scan incoming and outgoing mail for viruses if you build and configure a mail server.

1.1 Install

The clamav-related configuration files are installed in the /etc/clamav/ folder.

1.2 Virus Definition Update

Edit configuration file

Automatic virus definition update confirmation
Ensure that the service is registered for automatic virus definition updates.

Logs are recorded in the file /var/log/clamav/freshclam.log.

1.3 Virus Check Confirmation

①Running manual virus checks

Infected files: 0, so no virus

②Virus detection by downloading test viruses
Download a harmless virus and test it for detection.
Log in as a general user and check

As you can see, the virus is notified with the message "FOUND" and "Infected files: 1". The "--remove" option was also added, so the test virus was removed.

1.4  Create a script file to do a full scan

①Create a script file storage directory (/opt/script) in advance.

②Create script file

Contents of clam-full.sh (new)

③execute authorization

④Create a folder for virus quarantine
If not, a runtime error will occur because the above script specifies it as an excluded directory.

⑤Script Execution

Takes quite a long time to complete.
Logs are recorded in the /var/log/clamav/clamscan.log file.

⑤Scheduled virus scan execution with cron

In the above example, it runs regularly every Monday at 2:00 AM.

2. Mail server installation

Postfix was developed as a Mail Transport Agent (MTA) to replace sendmail, and is a mail server that is highly compatible with sendmail, secure, easy to maintain, and fast.
In addition, since Postfix only functions as an SMTP server for sending mail, the POP server Dovecot for receiving mail will be installed separately in the latter half.

2.1 Postfix : Installation Configuration

Install Postfix
Install Postfix and build an SMTP server; SMTP uses 25/TCP.
To prevent unauthorized mail relay, use the SASL function of Dovecot, described below, and configure Postfix so that authentication is also required for sending.

You will be asked to select general configuration settings, select "No configuration " to set them manually later

Edit configuration file (main.cf)

Editorial content

Edit configuration file (master.cf)

Editorial content

Reflect settings, reboot

2.2 Dovecot : Installation Configuration

①Install Dovecot
Install Dovecot and build a POP/IMAP server, using 110/TCP for POP and 143/TCP for IMAP.

Configure Dovecot to provide SASL functionality for Postfix

Reflect settings, reboot

2.3 Email User Account Registration

Register a user account for e-mail.
This setting is for when a user account on the OS is also used for e-mail.
If you want to use mail with a user account on the OS, no additional configuration is required, just register the OS user

Mail client installed

Mailboxes are set to refer to Maildir

2.4 Opening Ports

2.5 operation check ①

①Send test mail to yourself [mail (user name)@(host name)].
user name : huong

Ctrl + D key to exit the main text

 Check incoming mail

2.6 operation check ②

Set up and confirm your account in Mozilla Thunderbird

①Start Thunderbird, and click "Tools", "Account Settings".

②「Account Actions」「Add Mail Account」

③Your full name" is an optional name
Email addtess" is "huong@korodes.com" added earlier
Password" is the password for user huong
Click on "Configure manually"

④Set "INCOMMING SERVER" and "OUTGOING SERVER" as shown below and click "Re-test".

⑤The "Server Found" message appears.(The following settings were found by probinfg the given server)

After clicking "Done," the following "Warning" appears, but there is no problem, so click "Confirm.

⑥Click "Finish" when "Account syccessfuly created" is displayed.

3.Anti-virus and anti-spam measures(ClamAV + SpamAssassin)

Postfix is integrated with ClamAV for virus scanning and spam filtering.

3.1 ClamAV daemon, amavisd-new, SpamAssassin Install

3.2 SpamAssassin Editing Configuration Files

3.3 amavisd-new Editing Configuration Files

Integrate Postfix with ClamAV and SpamAssassin

3.4 Edit 15-content_filter_mode

3.5 Edit 15-av_scanners

3.6 Edit Postfix - main.cf

3.7 Edit Postfix - master.cf

3.8 Register your domain name

3.9 Setting Reflection

Auto-Startup

When you send a blank email, the header will show the following

X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Return-Path: xxxxx@korodes.com
X-Original-To: xxxxx@korodes.com
Delivered-To: xxxxx@korodes.com
Received: from localhost (localhost [127.0.0.1])
by mail.korodes.com (Postfix) with ESMTP id 8F707DFABA
for xxxxx@korodes.com; Sun, 6 Apr 2025 21:25:54 +0900 (JST)
X-Virus-Scanned: Debian amavisd-new at korodes.com
X-Spam-Flag: NO
X-Spam-Score: 5.111
X-Spam-Level: *
X-Spam-Status: No, score=5.111 tagged_above=2 required=6.31
tests=[ALL_TRUSTED=-1, EMPTY_MESSAGE=2.344, MISSING_SUBJECT=1.767,
PDS_TONAME_EQ_TOLOCAL_SHORT=1, PDS_TONAME_EQ_TOLOCAL_VSHORT=1]
autolearn=no autolearn_force=no
Received: from mail.korodes.com ([127.0.0.1])
by localhost (mail.korodes.com [127.0.0.1]) (amavisd-new, port 10024)

with ESMTP id 4et2CYHS88HK for xxxxx@korodes.com;
Sun, 6 Apr 2025 21:25:53 +0900 (JST)
Received: from [192.168.11.8] (xxxxxx.setup [192.168.11.1])
by mail.korodes.com (Postfix) with ESMTPA id 7A03BDFAA9
for xxxxx@korodes.com; Sun, 6 Apr 2025 21:25:53 +0900 (JST)
Message-ID: e898a2db-9903-4846-90da-2db1af012d7a@korodes.com
Date: Sun, 6 Apr 2025 21:25:53 +0900
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
From: xxxxx xxxxx@korodes.com
Content-Language: en-US
To: xxxxx xxxxx@korodes.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Copied title and URL