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 660and never expose TCP 3310 beyond the host or a trusted segment. - Real-time blocking needs fanotify permission events. Without
CONFIG_FANOTIFY_ACCESS_PERMISSIONS=yon-access scanning only notifies, whateverOnAccessPreventionsays. - 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
MaxFileSizeor archives overMaxScanSizeare skipped without an alert unlessAlertExceedsMaxis 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.
| Component | What it does | Use it for | Config file |
|---|---|---|---|
clamd | Multi-threaded scanning daemon; loads signatures once and listens on a Unix or TCP socket | Every server that scans more than occasionally | clamd.conf |
clamdscan | Client that sends scan jobs to clamd; performs quarantine actions (--move, --copy, --remove) | Scheduled scans of shares and upload areas | Reads clamd.conf for the socket |
clamscan | Standalone scanner; loads the database, scans, reports, exits | One-off checks, rescue media, signature testing | Command line options |
clamonacc | On-access client (0.102 and later) using Linux fanotify; runs as root and asks clamd to scan files as they are opened | File servers needing real-time detection or blocking | On-access settings in clamd.conf |
freshclam | Downloads and verifies signature databases, can notify clamd to reload | Every installation | freshclam.conf |
clamav-milter | Mail filter for Sendmail and Postfix milter interfaces; passes messages to clamd | MTAs and mail relays | clamav-milter.conf |
sigtool | Builds and inspects signatures and CVD files | Custom signatures, false positive work | Command 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.
| Directive | Documented default | Recommended for a server | Why |
|---|---|---|---|
LocalSocket | Disabled (must be set) | A path such as /run/clamav/clamd.ctl | Unix socket keeps scanning local and supports --fdpass |
LocalSocketMode | Disabled (socket world accessible) | 660 with a dedicated group | Stops any local user from driving the scanner |
TCPSocket / TCPAddr | Not set; the sample warns binding to INADDR_ANY is "probably not wise" | Leave unset, or bind to loopback or a management interface only | clamd does not authenticate or protect TCP traffic |
User | Do not drop privileges | clamav (or the package user) | Run unprivileged; use --fdpass for files it cannot read |
LogFile, LogSyslog, LogTime | Disabled, no | Enable syslog and timestamps | Detections must reach your SIEM |
MaxFileSize | 100M | Set to the largest legitimate file you expect | Larger files are not scanned |
MaxScanSize | 400M | Raise for archive-heavy shares, within memory budget | Caps data scanned per file including archive contents |
MaxRecursion / MaxFiles | 17 / 10000 | Keep defaults unless you see skipped archives | Limits on nested and multi-file archives |
AlertExceedsMax | no | yes | Turns silent skips into alerts you can review |
AlertEncrypted | no | yes on mail and upload paths | Encrypted archives cannot be inspected |
DetectPUA | no | Consider yes on upload areas after tuning | Flags potentially unwanted applications |
ConcurrentDatabaseReload | yes | Keep, unless memory is tight | Keeps scanning during reload at the cost of double memory |
SelfCheck | 600 seconds | Keep | Daemon 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 line | Status (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.7 | Four months after 1.7 is published |
| 1.4 LTS | Supported; patches until 15 August 2027 | 15 August 2028 |
| 1.0 LTS | End of life 28 November 2025 | 28 November 2026 |
| 0.105 and older | End of life | Blocked 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(orOnAccessExcludeUID) to the clamd user, or clamonacc can trigger scan loops on clamd's own reads. - Prevention versus notify: notify-only is the default.
OnAccessPrevention yesblocks 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:
OnAccessMountPathavoids watch limits but cannot be combined with include paths, exclude paths, prevention orOnAccessExtraScanning. It suits detection on whole mounts, not blocking. - On-access size cap:
OnAccessMaxFileSizedefaults to 5M, much lower than the scheduled-scan limit; raise it where larger documents arrive. - Quarantine: clamonacc and clamdscan accept
--moveor--copy. Avoid--removeexcept 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:
| Directive | Default | Notes |
|---|---|---|
MilterSocket / ClamdSocket | No default, must be set | Prefer Unix sockets; ClamdSocket unix:/run/clamav/clamd.ctl |
User | Not set (privileges not dropped) | Set to clamav |
OnInfected | Quarantine | Options: Accept, Reject, Defer, Blackhole, Quarantine. Reject at SMTP time tells the sender and avoids backscatter |
OnFail | Defer | Mail is deferred if clamd is down: monitor the queue, do not switch to Accept to clear it |
OnClean | Accept | Keep |
MaxFileSize | 25 MB | Messages above it are not scanned; align with the MTA message size limit |
AddHeader, LogInfected | Disabled | Enable a header for downstream filtering and LogInfected Basic or Full for evidence |
LocalNet, SkipAuthenticated | Not 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
- 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.
- Updates first: configure freshclam with logging,
NotifyClamdand anOnErrorExecutealert; for fleets, stand up a private mirror. - Daemon: configure clamd with a Unix socket,
LocalSocketMode 660,User clamav, syslog, andAlertExceedsMax yes. - 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.
- Pilot on-access in notify mode on one server for two weeks; measure scan latency and false positives before enabling
OnAccessPreventionon drop zones. - Mail: deploy clamav-milter with
OnInfected Quarantinefirst, review results, then decide whether to move to Reject. - Scheduled scans: run clamdscan with
--multiscan --fdpassagainst shares out of hours, with--moveto a quarantine directory owned by root. - Rollback: stop clamonacc to remove on-access impact instantly; set milter
OnInfectedback 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
OnAccessIncludePathversus the inventory. - Skipped content: count of
AlertExceedsMaxand encrypted archive alerts, reviewed weekly. - Milter failure rate: messages deferred under
OnFailper 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.
--removeon shared drives, deleting business files on a false positive with no copy kept.
Framework mapping
| Framework | Reference | ClamAV configuration that supports it |
|---|---|---|
| NIST SP 800-53 Rev 5 | SI-3 Malicious Code Protection | clamd, clamonacc, milter and scheduled scans; automatic freshclam updates |
| NIST SP 800-53 Rev 5 | SI-4 System Monitoring, AU-2 Event Logging | Syslog forwarding of detections and update errors |
| NIST CSF 2.0 | DE.CM-09 | Monitoring of file activity and content on servers |
| CIS Controls v8.1 | Control 10 Malware Defenses (10.1 deploy, 10.2 automatic signature updates) | Deployment coverage and freshclam |
| ISO/IEC 27001:2022 | Annex A 8.7 Protection against malware | Documented configuration, updates and monitoring |
| PCI DSS v4.0.1 | Requirement 5 (see the Linux Anti Malware Guide for sub-requirements) | Automatic updates, periodic plus real-time scanning, retained logs |
| MITRE ATT&CK | M1049 Antivirus/Antimalware | Signature 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
clamavuser. - freshclam logs, notifies clamd and alerts on errors; fleets use a monitored private mirror.
AlertExceedsMaxandAlertEncryptedare 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
OnFaildeferrals 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
- ClamAV Documentation: Configuration
- ClamAV Documentation: Scanning
- ClamAV Documentation: On-Access Scanning
- ClamAV project: clamd.conf.sample
- ClamAV project: clamav-milter.conf.sample
- ClamAV Documentation: End of Life Policy
- ClamAV Documentation: Hosting a Private Mirror
- ClamAV Documentation: Signatures
Related NHI Mgmt Group resources: Linux Anti Malware Guide · Exim and Postfix Mail Server Hardening Guide · File Upload Security Guide · M1049 Antivirus/Antimalware