Setup ClamAV local repository

1. Add entry for new entry in DNS for clamav server
	IP: 192.168.0.10
	A Record: clamav.acorp.local
2. Add network alias and enable IP
	cp /etc/sysconfig/network-scripts/eth0 /etc/sysconfig/network-scripts/eth0:1

	vim /etc/sysconfig/network-scripts/eth0:1

	#Change IPADDR
	IPADDR=192.168.0.10
	ifup eth0:1
3. Create a separate configuration file for clamav virtual host and create directory in html area
	vim /etc/httpd/conf.d/clamav.conf

	NameVirtualHost 10.91.1.38:80
	< VirtualHost 10.91.1.38:80>
	DocumentRoot /var/www/html/clamav
	ServerName   clamav.acorp.local
	Options Indexes MultiViews
	< /VirtualHost>


	mkdir /var/www/html/clamav

4. Create script to download the virus definitions and add to cron jobs
	vim /usr/local/sbin/clamav-download.sh

	#!/bin/bash
	cd /var/www/html/clamav || exit 1
	mv -f *.cvd* old/
	wget -q http://db.local.clamav.net/main.cvd || cp -rp old/main.cvd ./
	wget -q http://db.local.clamav.net/daily.cvd || cp -rp old/daily.cvd ./
	wget -q http://db.local.clamav.net/bytecode.cvd || cp -rp old/bytecode.cvd ./


	vim /etc/cron.d/updates

	0 0 * * * root /usr/local/sbin/clamav-download.sh
5. Change all servers to look at local database in freshclam configuration file
	vim /etc/freshclam.conf

DatabaseMirror  clamav.acorp.local
6. Create daily cron job to get regular updates. Ensure the cron.daily script (timings specified in /etc/crontab) happens after the virus definitions are downloaded.
vim /etc/cron.daily/freshclam

	#!/bin/sh
	### A simple update script for the clamav virus database.

	LOG_FILE="/var/log/clamav/freshclam.log"

	if [ ! -f "$LOG_FILE" ]; then
	touch "$LOG_FILE"
 	chmod 644 "$LOG_FILE"
 	chown clamav.clamav "$LOG_FILE"
 	fi

	/usr/bin/freshclam \
	--quiet \
 	--datadir="/var/clamav" \
 	--log="$LOG_FILE" \
 	--daemon-notify="/etc/clamd.conf"


Back to Resources