Join our Newsletter — 33% off our NHI Course
Home› Guides› ClamAV: Configure Linux Malware Scanning for Mail and…
Guide Endpoint Security

ClamAV: Configure Linux Malware Scanning for Mail and File Servers

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 14 min read
On this page

ClamAV is often installed on a Linux mail or file server to satisfy an audit line, then left running with defaults that scan nothing in real time, bind the daemon to every interface or quietly fail to update. This how-to covers the configuration that makes ClamAV a working control: the clamd daemon and its socket, scan limits, freshclam updates and version support, on-access scanning with fanotify, clamav-milter for mail, scheduled scans for file shares, custom signatures and false positives, and what to log. It is written for Linux administrators and security engineers who already decided ClamAV is the right tool; the policy question of whether and where Linux servers need anti-malware is covered in the Linux Anti Malware Guide. Directive names and defaults below come from the ClamAV project's own sample configuration files and documentation as checked in November 2026.

This is an independent guide from NHI Mgmt Group, based on ClamAV's public documentation as of November 2026. It is not sponsored or reviewed by Cisco Talos. Product features change, so confirm settings against ClamAV's current documentation.

Key takeaways

  • Use clamd, not clamscan, on servers. clamscan reloads the whole signature database on every run; clamdscan and clamonacc hand work to a resident daemon.
  • Lock the socket down. clamd does not authenticate or protect TCP traffic, so prefer a Unix socket with LocalSocketMode 660 and never expose TCP 3310 beyond the host or a trusted segment.
  • Real-time blocking needs fanotify permission events. Without CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y on-access scanning only notifies, whatever OnAccessPrevention says.
  • An unsupported version stops getting signatures. End-of-life releases may be blocked from the official database, and 0.105 and older already are; plan around the LTS line.
  • Size limits are silent gaps. Files over MaxFileSize or archives over MaxScanSize are skipped without an alert unless AlertExceedsMax is turned on.

Components and how they fit together

ClamAV is a set of programs around one engine, libclamav. Pick the ones that match each server's role rather than installing everything everywhere.

ComponentWhat it doesUse it forConfig file
clamdMulti-threaded scanning daemon; loads signatures once and listens on a Unix or TCP socketEvery server that scans more than occasionallyclamd.conf
clamdscanClient that sends scan jobs to clamd; performs quarantine actions (--move, --copy, --remove)Scheduled scans of shares and upload areasReads clamd.conf for the socket
clamscanStandalone scanner; loads the database, scans, reports, exitsOne-off checks, rescue media, signature testingCommand line options
clamonaccOn-access client (0.102 and later) using Linux fanotify; runs as root and asks clamd to scan files as they are openedFile servers needing real-time detection or blockingOn-access settings in clamd.conf
freshclamDownloads and verifies signature databases, can notify clamd to reloadEvery installationfreshclam.conf
clamav-milterMail filter for Sendmail and Postfix milter interfaces; passes messages to clamdMTAs and mail relaysclamav-milter.conf
sigtoolBuilds and inspects signatures and CVD filesCustom signatures, false positive workCommand line options

Generate starting files with clamconf -g clamd.conf, clamconf -g freshclam.conf and clamconf -g clamav-milter.conf, or copy the shipped .example or .sample files. The daemon treats a config file that still contains the line Example as invalid, so remove it. Distribution packages often ship their own paths and service units; follow the package's layout rather than mixing it with a source build.

Configure clamd safely

The daemon is where most risky defaults live. The documented defaults below come from the project's clamd.conf.sample.

DirectiveDocumented defaultRecommended for a serverWhy
LocalSocketDisabled (must be set)A path such as /run/clamav/clamd.ctlUnix socket keeps scanning local and supports --fdpass
LocalSocketModeDisabled (socket world accessible)660 with a dedicated groupStops any local user from driving the scanner
TCPSocket / TCPAddrNot set; the sample warns binding to INADDR_ANY is "probably not wise"Leave unset, or bind to loopback or a management interface onlyclamd does not authenticate or protect TCP traffic
UserDo not drop privilegesclamav (or the package user)Run unprivileged; use --fdpass for files it cannot read
LogFile, LogSyslog, LogTimeDisabled, noEnable syslog and timestampsDetections must reach your SIEM
MaxFileSize100MSet to the largest legitimate file you expectLarger files are not scanned
MaxScanSize400MRaise for archive-heavy shares, within memory budgetCaps data scanned per file including archive contents
MaxRecursion / MaxFiles17 / 10000Keep defaults unless you see skipped archivesLimits on nested and multi-file archives
AlertExceedsMaxnoyesTurns silent skips into alerts you can review
AlertEncryptednoyes on mail and upload pathsEncrypted archives cannot be inspected
DetectPUAnoConsider yes on upload areas after tuningFlags potentially unwanted applications
ConcurrentDatabaseReloadyesKeep, unless memory is tightKeeps scanning during reload at the cost of double memory
SelfCheck600 secondsKeepDaemon checks database integrity and freshness

Two behaviours catch people out. Over a Unix socket clamd opens paths itself, so the daemon user needs read access to everything scanned; clamdscan --fdpass makes the client open each file and pass the descriptor instead (Unix sockets only). And clamd reopens its log on SIGHUP and reloads the database on SIGUSR2, which is what logrotate and update hooks should send. If many local clients share the daemon, raise MaxThreads (default 10) only after watching queueing.

Signature updates and version support

freshclam fetches the official databases (main.cvd, daily.cvd and the bytecode database), which are digitally signed containers maintained by Cisco Talos. Set NotifyClamd so the daemon reloads after an update (default no), UpdateLogFile or syslog for evidence, and keep TestDatabases yes (default) so a broken download is rejected before clamd loads it. The default Checks 12 means every two hours. When running from cron instead of freshclam -d, the documentation asks you to choose a minute between 3 and 57 that is not a multiple of 10, to spread load on the mirror network. If HTTPProxyPassword is set, restrict the file's permissions.

OnUpdateExecute and OnErrorExecute run a command after success or failure; use the error hook to raise an alert, because a server that silently stops updating is the most common ClamAV failure.

Private mirrors for fleets and isolated networks

Official CVD downloads are rate limited by IP address, so many servers behind one NAT address can be throttled. For fleets, or servers with no internet access, run a private mirror. The project documents two patterns: a cvdupdate based mirror serving CVD and CDIFF files, which clients use through DatabaseMirror, and a freshclam based mirror serving whole CVD or CLD files, which clients use through PrivateMirror with ScriptedUpdates no. Run the mirror's own update at least daily and monitor its freshness, because every client inherits its staleness.

Stay on a supported release

Release lineStatus (as published by ClamAV, checked November 2026)Signature downloads until
1.5 (regular feature release)Supported; patches until four months after 1.6 or until 1.7Four months after 1.7 is published
1.4 LTSSupported; patches until 15 August 202715 August 2028
1.0 LTSEnd of life 28 November 202528 November 2026
0.105 and olderEnd of lifeBlocked from new updates

LTS releases receive critical patches for at least three years and signature access for one further year; regular releases are supported much more briefly. The project also reserves the right to block older patch versions four months after a newer patch is released, so staying on the latest patch of your line matters, not just the line. Servers still on 1.0 should be moved to 1.4 LTS or later now.

On-access scanning on file servers

clamonacc uses fanotify, which needs Linux kernel 3.8 or later and curl 7.45 or later. Check the kernel with grep FANOTIFY /boot/config-$(uname -r): you need CONFIG_FANOTIFY=y for detection and CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y for blocking. Start clamd first, then clamonacc as root. Without --log it runs silently.

  • Scope with OnAccessIncludePath: list the share roots, upload directories and home areas you need, one directive per path. / is refused by design, because blocking system files can lock the host, and the documentation warns against approximating whole-system coverage with many include paths.
  • Exclude the scanner: set OnAccessExcludeUname (or OnAccessExcludeUID) to the clamd user, or clamonacc can trigger scan loops on clamd's own reads.
  • Prevention versus notify: notify-only is the default. OnAccessPrevention yes blocks access to detected files but the documentation warns it seriously affects performance on busy directories, so use it on drop zones and upload paths, not on every share.
  • Watch limits: include paths are tracked through inotify (Dynamic Directory Determination). The default watch limit of 8192 is too low for large shares; the documentation suggests 524288 for fs.inotify.max_user_watches.
  • Mount path mode: OnAccessMountPath avoids watch limits but cannot be combined with include paths, exclude paths, prevention or OnAccessExtraScanning. It suits detection on whole mounts, not blocking.
  • On-access size cap: OnAccessMaxFileSize defaults to 5M, much lower than the scheduled-scan limit; raise it where larger documents arrive.
  • Quarantine: clamonacc and clamdscan accept --move or --copy. Avoid --remove except on upload or download directories, because a false positive then deletes a business file.

For SMB shares, scanning on the Linux host covers files written through Samba as well as local writes. For NAS appliances that cannot run clamonacc, schedule clamdscan from a host with the share mounted read-only. See the NAS Ransomware Playbook for what to do when a share is hit.

Mail servers with clamav-milter

clamav-milter connects the MTA's milter interface to clamd and needs a working clamd. It must be built with -D ENABLE_MILTER=ON and libmilter, or installed from a distribution package. Defaults from clamav-milter.conf.sample:

DirectiveDefaultNotes
MilterSocket / ClamdSocketNo default, must be setPrefer Unix sockets; ClamdSocket unix:/run/clamav/clamd.ctl
UserNot set (privileges not dropped)Set to clamav
OnInfectedQuarantineOptions: Accept, Reject, Defer, Blackhole, Quarantine. Reject at SMTP time tells the sender and avoids backscatter
OnFailDeferMail is deferred if clamd is down: monitor the queue, do not switch to Accept to clear it
OnCleanAcceptKeep
MaxFileSize25 MBMessages above it are not scanned; align with the MTA message size limit
AddHeader, LogInfectedDisabledEnable a header for downstream filtering and LogInfected Basic or Full for evidence
LocalNet, SkipAuthenticatedNot set (scan everything)Do not skip internal or authenticated senders: compromised accounts send malware too

ClamAV is one layer of mail filtering, not a secure email gateway. Pair it with MTA hardening from the Exim and Postfix Mail Server Hardening Guide.

Custom signatures and false positives

Put local signature files in the database directory (for example /usr/local/share/clamav, or your package's DatabaseDirectory). Useful types are .hdb and .hsb file hash signatures, .ndb body signatures, .ldb logical signatures and YARA rules (.yar, .yara, supported since 0.99). Build hash signatures with sigtool --sha256 and check a rule with sigtool --test-sigs or clamscan -d rule.ldb sample; note that clamscan -d loads only the files you name, so the official signatures and some unpacking checks are not active in that test.

Handle false positives with allow-list files rather than turning detection off: .fp or .sfp to allow a specific file by hash, and .ign2 to ignore a named signature. Keep these files in version control with a ticket reference per line and review them quarterly, because an allow-list entry is a permanent blind spot. Report false positives to the ClamAV project so the official database is corrected.

How to implement

  1. Baseline: install from your distribution or the project's packages on a supported line (1.4 LTS or later), record the version in your asset inventory.
  2. Updates first: configure freshclam with logging, NotifyClamd and an OnErrorExecute alert; for fleets, stand up a private mirror.
  3. Daemon: configure clamd with a Unix socket, LocalSocketMode 660, User clamav, syslog, and AlertExceedsMax yes.
  4. Test detection: use the EICAR test file, an industry standard harmless test string, to confirm clamdscan, clamonacc and the milter each detect, log and quarantine as expected.
  5. Pilot on-access in notify mode on one server for two weeks; measure scan latency and false positives before enabling OnAccessPrevention on drop zones.
  6. Mail: deploy clamav-milter with OnInfected Quarantine first, review results, then decide whether to move to Reject.
  7. Scheduled scans: run clamdscan with --multiscan --fdpass against shares out of hours, with --move to a quarantine directory owned by root.
  8. Rollback: stop clamonacc to remove on-access impact instantly; set milter OnInfected back to Quarantine; keep the previous package version available for downgrade within the same supported line.

Detection and measurement

Forward clamd, clamonacc, freshclam and milter logs to your SIEM. Alert on any detection line (FOUND), on freshclam errors, and on clamd not running.

  • Signature age: hours since the last successful freshclam update per host (alert above 24).
  • Supported version coverage: percentage of hosts on a supported ClamAV release and latest patch (target 100 per cent).
  • On-access coverage: share roots and upload paths under OnAccessIncludePath versus the inventory.
  • Skipped content: count of AlertExceedsMax and encrypted archive alerts, reviewed weekly.
  • Milter failure rate: messages deferred under OnFail per day (target near zero).
  • False positive rate: allow-list additions per month, each with a ticket.

Where identity fits

ClamAV itself runs as service identities: the clamav user for clamd and freshclam, root for clamonacc, and whatever account a scheduled scan job uses. Keep each one non-interactive, owned and least privileged, keep the database directory owned by DatabaseOwner only, and do not give scan jobs write access beyond the quarantine directory. A private mirror is a software distribution point for every scanner in the fleet, so protect its host and update account like other service accounts.

Common failure patterns

  • clamd listening on TCP 3310 on all interfaces, letting anyone on the network submit work to an unauthenticated daemon.
  • freshclam failing for weeks because the version reached end of life or the NAT address was rate limited, with no alert configured.
  • On-access "enabled" on a kernel without fanotify permission events, so prevention is silently notify-only.
  • Large files and archives skipped silently because size limits were left at defaults without AlertExceedsMax.
  • clamscan in cron on busy hosts, reloading the database each run and overlapping itself.
  • --remove on shared drives, deleting business files on a false positive with no copy kept.

Framework mapping

FrameworkReferenceClamAV configuration that supports it
NIST SP 800-53 Rev 5SI-3 Malicious Code Protectionclamd, clamonacc, milter and scheduled scans; automatic freshclam updates
NIST SP 800-53 Rev 5SI-4 System Monitoring, AU-2 Event LoggingSyslog forwarding of detections and update errors
NIST CSF 2.0DE.CM-09Monitoring of file activity and content on servers
CIS Controls v8.1Control 10 Malware Defenses (10.1 deploy, 10.2 automatic signature updates)Deployment coverage and freshclam
ISO/IEC 27001:2022Annex A 8.7 Protection against malwareDocumented configuration, updates and monitoring
PCI DSS v4.0.1Requirement 5 (see the Linux Anti Malware Guide for sub-requirements)Automatic updates, periodic plus real-time scanning, retained logs
MITRE ATT&CKM1049 Antivirus/AntimalwareSignature scanning on Linux servers

Practitioner checklist

  • Every ClamAV host is on a supported release and the latest patch of its line.
  • clamd uses a Unix socket with mode 660, or TCP bound to loopback or a management interface only.
  • clamd, freshclam and the milter drop privileges to the clamav user.
  • freshclam logs, notifies clamd and alerts on errors; fleets use a monitored private mirror.
  • AlertExceedsMax and AlertEncrypted are on and their alerts reviewed.
  • On-access is scoped with include paths, excludes the clamd user, and prevention is used only where tested.
  • Kernel fanotify permission support is confirmed wherever blocking is claimed.
  • clamav-milter does not skip internal or authenticated senders and OnFail deferrals are monitored.
  • Allow-list files are version controlled, ticketed and reviewed quarterly.
  • Detection is tested with the EICAR file after every upgrade.

Standards and references

Related NHI Mgmt Group resources: Linux Anti Malware Guide · Exim and Postfix Mail Server Hardening Guide · File Upload Security Guide · M1049 Antivirus/Antimalware

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.